Re: Remote execute batch
- From: Corey Thomas - MCSE/MCSA/MCDBA <CoreyThomasMCSEMCSAMCDBA@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 27 Mar 2008 06:33:01 -0700
You can also create a batch file to kick off the script. Then create a
scheduled task with the appropriate credentials. You can then run it with
admin rights if needed.
For something like this, I usually prefer the scheduled task because it can
be faster than remote code execution.
-Corey
"Tom Lavedas" wrote:
On Mar 26, 1:13 pm, "Pegasus \(MVP\)" <I....@xxxxxxxxxx> wrote:.
"freddy" <fre...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1FA26BE6-DE94-458D-B7C3-7DABA342BE09@xxxxxxxxxxxxxxxx
I have a script that goes out to each computer in a text file and check the
EPO version. If the versions are different than copy a file from the local
machine to the remote machine and execute the batch file on the remote the
problem is that it execute on the local machine - Why?
Here is the script. Thank You
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/
- References:
- Re: Remote execute batch
- From: Pegasus \(MVP\)
- Re: Remote execute batch
- From: Tom Lavedas
- Re: Remote execute batch
- Prev by Date: RE: Scripting a group polocy update
- Next by Date: Re: Extracting data from an XML to put into a constant
- Previous by thread: Re: Remote execute batch
- Next by thread: Re: Remote execute batch
- Index(es):
Relevant Pages
|