5.2. Running a Task on a Remote Server
You want to run a task on a remote server. By this, I don't mean running a task against a remote server, but the command or script actually runs on the remote server. This is useful if the tool you want to use can only be run locally on a system, or if it generates a lot of network traffic and could work more efficiently if run locally.
Using a graphical user interface
To run a command or utility on a remote computer via a graphical interface, you'll need to use a remote desktop application like Remote Desktop or VNC.
Using a command-line interface
The following command executes the diruse utility on the host fs01 to find directories that contain more than 100 MB of data:
> psexec \\fs01 c:\tools\diruse.exe /s /m /d /q:100 c:\
This assumes that c:\tools\diruse.exe exists on fs01. You can also have psexec copy the command you want to run
from the local system to the target system by specifying the
-c option. The following command
executes the same one as before, except the diruse utility is copied to the target
> psexec \\fs01 -c diruse.exe /s /m /d /q:100 c:\
As with other Sysinternals tools, you can specify alternate
credentials with psexec using
-u option. Here is an
> psexec \\fs01 -u CORP\rallen -c c:\diruse.exe /s /m /d /q:100 c:\
' This code shows how to run a task on a remote server. ' ------ SCRIPT CONFIGURATION ------ strComputer = "
<ServerName>" strCommand = "cscript.exe c:\scripts\dircheck.vbs" ...