Re: Remote execute batch

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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/

.



Relevant Pages

  • Re: Time Log
    ... The script does execute as you hoped. ... but I can't get remote execution of the script working. ... Dim objFileSystem, objOutputFile ...
    (microsoft.public.scripting.vbscript)
  • Re: Catching Remote Errors in calling script
    ... causes a general error to be returned to the calling script. ... // yields the Error object which should have been created in line above. ... but it's as if remote execution causes a remote error itself. ...
    (microsoft.public.scripting.wsh)
  • Re: Catching Remote Errors in calling script
    ... The calling and remote scripts actually work - but in the calling script I ... have to ignore the specific error object that is returned ... but it's as if remote execution causes a remote error ...
    (microsoft.public.scripting.wsh)
  • Re: Catching Remote Errors in calling script
    ... the script that is invoking the remote script waits for the remote script to ... but when remotely I always get the same generic error object. ... but it's as if remote execution causes a remote error itself. ...
    (microsoft.public.scripting.wsh)
  • Re: batch file to install printer
    ... want to add a printer in a logon script, ... who has administrative rights on the remote computer. ... script logged in as the domain administrator and pass the name of the remote ... run a Batch File that Installs a Local TCP/IP Printer with a specific IP ...
    (microsoft.public.windowsxp.print_fax)