Const HKEY_LOCAL_MACHINE = &H80000002
Const ForReading = 1
Dim shell
Set shell = CreateObject("WScript.shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\scripts\EPO.txt", ForReading)
Do Until objTextFile.AtEndOfStream
strComputer = objTextFile.Readline
Path = ("\\"& strComputer & "\C$\Program Files\Network Associates\Common
Framework\FrameworkService.exe")
Verison = objFSO.GetFileVersion (Path)
Current = "3.6.0.546"
If version = Current Then
WScript.Echo " Version are equal"
Else
WScript.Echo " Version are not equal"
set objWMIService = getobject("winmgmts://"_
& strComputer & "/root/cimv2")
objFSO.CopyFolder "C:\EPO_Agent_McAfee_85i\2007\EPO_3.60_Patch1", "\\" &
strComputer & "\c$\temp\"
WScript.Echo "Copy Done, running batch file for updating EPO"
Net use
shell.Run "c:\temp\EPO_3.60_Patch1\install.bat"
End If
WScript.Echo strComputer & ":" & " EPO File Version is " &
objFSO.GetFileVersion (Path)
Loop
objTextFile.Close
AFAIK you need a tool such as psexec.exe to run a program
on a remote machine. You could wrap the whole job into a
single batch file: Check the version, then run the update.
WSH 5.6 supports remote execution via the WSHController class and its
methods. I've never used it, but have seen discussions. The target
machine has to be enabled (registry setting) to permit remote
scripting, but as I said, I've never actually done it so I can't give
chapter and verse. See the WSH documentation for more info ...
Example from docs ...
Dim Controller, RemoteScript
Set Controller = WScript.CreateObject("WSHController")
strComputer = "remoteservername" ' in UNC
Set RemoteScript = Controller.CreateScript("remote1.js", strComputer)
RemoteScript.Execute
Do While RemoteScript.Status <> 2
WScript.Sleep 100
Loop
Change "remote1.js" to "c:\temp\EPO_3.60_Patch1\install.bat" in this
instance. That needs to be a local path, not on the target machine, I
think. CreateScript method performs the copy to a temporary location
on the
WMI also has a class that supports remote execution. I forget which
class. I suspect that a groups.google search of "remote execution" or
"run remote script" or some such with the word "remote" will yield
more than a few threads that discuss both of these (as well as
psexec).
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
For something like this, I usually prefer the scheduled task because it can
be faster than remote code execution.
-Corey
The Run method of the wshShell object executes the command locally. I have
an example VBScript program that deploys executables to remote computers
linked here:
http://www.rlmueller.net/Deploy.htm
This example deploys to the computers in a domain group. I find that easier
to manage. The Create method of the Win32_Process class is used to run the
executable on the remote computer, which must run silently. The program
waits for the executable to finish, then deletes it. I find that a mapped
drive must be used. The program keeps a detailed log. Hopefully this helps.
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
I was unable to get your script to run due to persistent ActiveX
errors but I had no problem with the following script, copied
straight from the Scripting Guy column. In the code below,
c:\Test.bat resides in \\remote\c$.
strComputer = "remote"
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
objWMIService.Create "c:\test.bat", Null, Null, intProcessID
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
We don't actually need the last line - this will suffice: