Partager via


Remote Examples

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2

Remote Examples

Example 1: Interact with a batch program running on a remote server

In this example, you must first create a batch program on the server (Remoteserver3 in this case). To create the batch program, you can use any text editor, such as Notepad, or the copy con command at the command prompt as follows:

 
copy con testprog.bat 
pause 
schtasks /? 
pause 
^Z 

Press CTRL+Z (^Z) to end the copy con session and save the Testprog.bat file in the default directory.

On the server

To start the remote session at the server, type the following on the server at the command line:

remote /s "testprog.bat" testsession1

You will see output similar to the following, confirming that the remote server received the command to continue executing the batch file Testprog.bat:

C:\Program Files\Support Tools>remote /s "testprog.bat" "testsession1"

************************************ ********** REMOTE *********** ********** SERVER *********** ************************************ To Connect: Remote /C REMOTESERVER3 "testsession1"

C:\Program Files\Support Tools>pause
Press any key to continue . . .

This indicates that Testprog.bat started, then paused, waiting for any key to be pressed before continuing as instructed in the batch program.

On the client

On the client computer, open a command window and type the following at the command prompt:

remote /c remoteserver3 "testsession1"

On the client computer, you will see output confirming that the remote server received the command to continue executing the batch file Testprog.bat, as follows:

C:\Program Files\Support Tools>remote /c remoteserver3 "testsession1"

************************************ ********** REMOTE *********** ********** CLIENT *********** ************************************ Connected...

C:\Program Files\Support Tools>pause
Press any key to continue . . .
**Remote: Connected to REMOTESERVER3 administrator1 [Sun 3:27 PM]

Client-server interaction

After establishing the client-server interactive session, you can press any key to continue running the program, (in this case we use the Enter key). When Testprog.bat continues on the server, you will see output similar to that shown below.

Server output looks like this:

**Remote: Connected to REMOTESERVER3 administrator1 [Sun 3:27 PM]
^M                      [CLIENTCOMPUTER7 3:27 PM]


C:\Program Files\Support Tools>schtasks /?

SCHTASKS /parameter [arguments]

Description:
    Enables an administrator to create, delete, query CHange, run and
    end scheduled tasks on a local or remote system. Replaces AT.exe.

Parameter List:
    /Create         Creates a new scheduled task.

    /Delete         Deletes the scheduled task(s).

    /Query          Displays all scheduled tasks.

    /Change         Changes the properties of scheduled task.

    /Run            Runs the scheduled task immediately.

    /End            Stops the currently running scheduled task.

    /?              Displays this help/usage.

Examples:
    SCHTASKS
    SCHTASKS /?
    SCHTASKS /Run /?
    SCHTASKS /End /?
    SCHTASKS /Create /?
    SCHTASKS /Delete /?
    SCHTASKS /Query  /?
    SCHTASKS /Change /?

Remote exiting. Child (testprog.bat) exit code was 0.

Client output (Clientcomputer7 in this case) is similar to output from the server Remoteserver3, as shown here:


C:\Program Files\Support Tools>schtasks /?

SCHTASKS /parameter [arguments]

Description:
    Enables an administrator to create, delete, query CHange, run and
    end scheduled tasks on a local or remote system. Replaces AT.exe.

Parameter List:
    /Create         Creates a new scheduled task.

    /Delete         Deletes the scheduled task(s).

    /Query          Displays all scheduled tasks.

    /Change         Changes the properties of scheduled task.

    /Run            Runs the scheduled task immediately.

    /End            Stops the currently running scheduled task.

    /?              Displays this help/usage.

_** SESSION OVER **_

Note

  • The session on both the client and the server computers ends the moment the remote command completes. In some cases, the output to the client computer might be truncated if the remote command terminates before all the output is sent to the client. In this example, the remote command (schtasks /?) is delayed from terminating by the Pause statement that occurs after the schtsks /? command.

Example 2: Example of a keyword/color file

The following command creates a keyword-highlighting scheme on the client command console using the text file Colorscheme.txt:

 
remote /c server3 remotesession2 /k colorscheme.txt

In this example, the format of the Colorscheme.txt text file is as follows:

 
Error 
red 
Continue 
lblue, white 
WaRnInG 
white, purple 

When used in conjunction with the /K parameter, this file causes all instances of the word "error" to be highlighted in red, "continue" to be highlighted in light blue with a white background, and "warning" to be highlighted in white with a purple background. Keywords are case-insensitive.

See Also

Concepts

Remote Overview
Remote Remarks
Remote Syntax
Alphabetical List of Tools
Windiff Overview
Poolmon Overview
Msizap Overview
Msicuu Overview
Memsnap Overview
Gflags.exe
Devcon Overview