Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Active Directory - VBS Computer Policy Script

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,32477
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Active Directory - VBS Computer Policy Script
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Active Directory - VBS Computer Policy Script - 3/21/2006 5:10:33 AM   
  tbraga

 

Posts: 41
Score: 0
Joined: 2/1/2006
Status: offline
Hi All,

I have this script (below) that I have written.  It copies some files then checks against the registry and if a specific key is not found then it continues down the if statement to install an application.  Lastly it places that registry key within the registry, therefore it will only run the executable once. 

I am running this through Active Directory's Group Policy as a computer startup script.  The script itself works fine, the logic and syntax is correct but when i apply it to the computer it doesn't write to the registry or do anything with the registry for that matter...but it does copy the files, therefore it must be something with the registry.  everything works fine when i set it as a user login script but i am trying to avoid that.

I feel it is a permissions thing with the registry and was wondering if anyone had dealt with this type of issue before. 
Thanks,
Tim

'*******************************************************************'
' Tim Braga                                                        *'
' 02/16/2006                                                    *'
' Script : This scripts launches the .BAT for installation of      *'
'          Prolog Manager 7.5 SP2                            *'
'*******************************************************************'

'*******************************************************************'
' Set Variables and Apply Libraries                                *'
'*******************************************************************'


On error resume next
Set WSHShell = WScript.CreateObject("WScript.Shell")
test = wshshell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Shawmut\GPO\PrologManager75SP2\PrologManager75SP2")
CitrixW = "W:"
CitrixX = "X:"

'******************************************************************************'
' IF Statement - IF Ultipro953 Registry Key Exists, Abort, Else Run Bat File  *'
'     IF W or X Drives exists, Abort                               *'
'******************************************************************************'

Const OverwriteExisting = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "c:\shawmut\super\safety\*" , "c:\test\", OverwriteExisting
 
' If test > 0 Then
' MsgBox("RegKey Exists")
' Else
' MsgBox("RegKey Doesn't Exists")
' end if
' wscript.echo test


' If test > 0 Then
' WScript.Quit
' Else
' WSHShell.Run "\\sdc-ris\MSI_Package\Prolog75SP2\Meridian_Systems_Prolog_Manager_75SP2.exe"
' end if
' wscript.echo test

'******************************************************************************'
' Merge Registry Entry - (HKLM)              *'                                        *'
'******************************************************************************'

WshShell.run "regedit /S ""\\sdc-ris\MSI_Package\Prolog75SP2\Prolog75SP2_Installed.reg""",0,True
 
 
Post #: 1
 
 RE: Active Directory - VBS Computer Policy Script - 3/21/2006 5:42:00 AM   
  tbraga

 

Posts: 41
Score: 0
Joined: 2/1/2006
Status: offline
Also, I would like to add an IF Statement to the script that says:

IF the operating system = Server2000 and Server2003 then quit
Else .....

Any idea's?

(in reply to tbraga)
 
 
Post #: 2
 
 RE: Active Directory - VBS Computer Policy Script - 3/22/2006 5:14:54 AM   
  ziminski

 

Posts: 79
Score: 2
Joined: 1/8/2006
Status: offline
this will return the os and version:
Set objWMIService = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
Wscript.Echo "OS Name: " & objOperatingSystem.Caption
Wscript.Echo "Version: " & objOperatingSystem.Version
Next

(in reply to tbraga)
 
 
Post #: 3
 
 RE: Active Directory - VBS Computer Policy Script - 3/22/2006 6:15:06 AM   
  tbraga

 

Posts: 41
Score: 0
Joined: 2/1/2006
Status: offline
Thanks Man,

I have added the last statemet fairly quickly and was wondering what i am doing wrong?  Any idea's?

Thanks,
Tim

Set objWMIService = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
Wscript.Echo "OS Name: " & objOperatingSystem.Caption
Wscript.Echo "Version: " & objOperatingSystem.Version
Next

If objOperatingSystem.Version = Microsoft Windows XP Professional Then
msgbox("Microsoft Windows XP Professional")
Else WScript.Quit

(in reply to ziminski)
 
 
Post #: 4
 
 RE: Active Directory - VBS Computer Policy Script - 3/22/2006 6:53:09 AM   
  tbraga

 

Posts: 41
Score: 0
Joined: 2/1/2006
Status: offline
Ok, I have the IF statement partially working.  It is always spitting out WinXP even when I change what the if statement is looking for knowing the outcome will be false.

On Error Resume Next
Set colOperatingSystems = objWMIService.ExecQuery _
   ("Select * from Win32_OperatingSystem")
 
If (objOperatingSystem.Caption = "Microsoft Windows XP Professional" OR objOperatingSystem.Caption = "Microsoft Windows 2000 Professional" ) Then
MsgBox("WinXP or Win2K")
Else WScript.Quit
End If



Any Idea's?????

(in reply to tbraga)
 
 
Post #: 5
 
 RE: Active Directory - VBS Computer Policy Script - 3/23/2006 2:12:55 AM   
  jluis

 

Posts: 5
Score: 0
Joined: 10/26/2005
Status: offline
hello


I detect versions trhought a *.bat file


      

Well the point of this script is that I use dos command ver and find a string in hope you can adapt my script to your needs...

(in reply to tbraga)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Active Directory - VBS Computer Policy Script Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts