[dba-Tech] script help

John Bartow john at winhaven.net
Wed Jan 30 15:02:08 CST 2013


Could someone please read through this and see why I'm getting a compile
error?
It's a pretty simple script but I'm obviously blinded by over familiarity
right now.

----------------------------------------------------------------------------
------------------------------
Dim WshShell, oExec, OSbit64, FSO, bResendDSC, ProgramPath, ViprePath,
AgentPath
 Set WshShell = CreateObject("WScript.Shell")
 Set FSO = CreateObject("Scripting.FileSystemObject")
 
 If OSbit64() Then 
	MsgBox "It's 64-bit!"
     ProgramPath = "C:\Program Files (x86)\" 
 Else 
	MsgBox "It's 32-bit!"
     ProgramPath = "C:\Program Files\"
 End If 
 
 If FSO.FolderExists(ProgramPath & "GFI Software\VIPRE") Then
     ViprePath= ProgramPath & "GFI Software\VIPRE"
 Else
     wscript.Echo "Vipre Folder Not Found."
 End If

 If FSO.FolderExists(ProgramPath & "\Advanced Monitoring Agent") Then
     AgentPath= ProgramPath & "\Advanced Monitoring Agent"
 Else
     wscript.Echo "Agent Folder Not Found."
 End If 

 ViprePath = Chr(34) & ViprePath& "\SBAMCommandLineScanner.exe" & Chr(34) &
" /updatedefs"
 AgentPath = Chr(34) & AgentPath & "\winagent.exe" & Chr(34)
 
 bResendDSC = True
 Set oExec = WshShell.Exec(ViprePath)
 
 Do While oExec.Status <> 1
     WScript.Sleep 100
 Loop
 
 Do While oExec.StdOut.AtEndOfStream <> True 
     If oExec.StdOut.ReadLine = "DONE:Update not needed" Then
         bResendDSC = False
     End If
 Loop
 
 If bResendDSC = True Then 
     RestartDSC
     wscript.Echo "Updating Vipre and resending Daily Service Check"
 Else
     wscript.Echo "Vipre is up to date"
 End If
 
 Sub RestartDSC()
     'Stop agent Service
     Set oExec = WshShell.Exec(AgentPath & " /stopservice")
 
     Do While oExec.Status <> 1
         WScript.Sleep 100
     Loop
 
     'Reset DSC Counter
     Set oExec = WshShell.Exec(AgentPath & " /testreset")
 
     Do While oExec.Status <> 1
         WScript.Sleep 100
     Loop
 
     'Restart Service
     Set oExec = WshShell.Exec(AgentPath & " /startservice")
 
     Do While oExec.Status <> 1
         WScript.Sleep 100
     Loop
 End Sub

Function OSbit64() 
 ' This works on Windows 2000, XP, Vista, 7, as well as Server 2000, 2003,
and 2008 
 Const HKLM = &H80000002 
 Dim strComputer, WshShell, sOSBit 
  strComputer = "." 
  Set WshShell = WScript.CreateObject("WScript.Shell") 
  OSbit64 = True 
  sOSbit = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment\PROCESSOR_ARCHITECTURE") 
  If sOSBit = "x86" Then 
	OSbit64 = False 
  End If 
  Set WshShell = Nothing 
End Function



More information about the dba-Tech mailing list