Basic Commands


-P-



PAUSE
Pauses script execution.

Syntax:
1. PAUSE

The PAUSE command execution of the script command and displays the prompt "Press any key to continue.". Script execution when any key is pressed, except Ctrl+C, which terminates script execution.

See also: SLEEP, CHOICE, TIMEOUT


PERMCOPY (Windows NT Resource Kit)
Copies share permissions.

Syntax:
1. PERMCOPY \\srccomputer srcshare \\dstcomputer dstshare

The PERMCOPY command copies access rights (ACLs) from one share to another, either on the same or a different server. PERMCOPY cannot copy to or from system maintained shares (such as C$).

To copy permissions, specify a source computer and share name, and a destination computer and share name.

Example:
permcopy \\styx files1 \\arbiter files2


PING
Probably the most important tool the Packet INternet Groper is used to check TCP/IP connection between two hosts. This makes use of the ICMP Echo command and makes 4 requests for a response from a host. When testing TCP/IP use the following routine:

Ping 127.0.0.1
Ping your IP address
Ping localhost
Ping default gateway
Ping remote host

Be aware ping is checking the whole communication. If it fails there is equally likely to be a fault on the other device's configuration. Try pinging a different machine and if you find that ping does not return from any other machine then it looks like your machine may have the problem.

Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [-r count] [-s count] [[-j host-list] | [-k host-list]] [-w timeout] destination-list

Options:
-t Ping the specified host until stopped. To see statistics and continue - type Control-Break; To stop - type Control-C.
-a Resolve addresses to hostnames.
-n count Number of echo requests to send.
-l size Send buffer size.
-f Set Don't Fragment flag in packet.
-i TTL Time To Live.
-v TOS Type Of Service.
-r count Record route for count hops.
-s count Timestamp for count hops.
-j host-list Loose source route along host-list.
-k host-list Strict source route along host-list.
-w timeout Timeout in milliseconds to wait for each reply.

See also Ping the Magic Duck!


POPD
Restores previously saved drive and directory.

Syntax:
1. POPD

The POPD command reverses the operation of the PUSHD command by recovering the most recently saved drive and directory from the save stack.

If the previous PUSHD maped a UNC name, which resulted in the allocation of a temporary drive letter, POPD deletes the drive mapping and releases the drive letter.

See also PUSHD, CHDIR


PULIST (Windows NT Resource Kit)
Displays process and user accounts.

Syntax:
1. PULIST [\\computer] [\\computer...]

The PULIST command displays a list of executing processes on each of the computers specified. Processes executing on the local computer are displayed if no computer names are specified. The list specifies the process executable, the process ID assigned by the system, and (for the local computer only) the user name associated with the process.

The process ID can be used as an argument to the KILL command.

See also: KILL


-Q-


-R-



RCP
RCP is similar to RSH in that it doesn’t require the user to log in, but does require the correct information to be present in the .rhosts file. RCP allows files to be copied between the two machines in communication.


RD
See RMDIR.


RENAME
See REN.


REXEC
Runs a command on a remote host. This client side tool is included in NT and requires a password for the remote system.


ROUTE
The ROUTE command allows you to view and edit entries in the routing table and to add new entries.

To view existing entries:
ROUTE PRINT

To add a new entry:
ROUTE ADD (destination network ID) MASK (subnet mask)(default gateway) METRIC (hops)


RSH
Runs a command on a remote host running the RSH daemon. Only the client is included with NT although an RSH daemon can be obtained in the resource kit. This tool does not prompt for a password however the users name needs to be configured in an .rhosts file. This file will need to be created from the command prompt as explorer will not allow it.

-S-


SC
SC is a command line program used for communicating with the NT Service Controller and services. Syntax:

        sc  [command] [service name]  ...

        The option  has the form "\\ServerName"
        Further help on commands can be obtained by typing: "sc [command]"
        Commands:
          query-----------Queries the status for a service, or
                          enumerates the status for types of services.
          queryex---------Queries the extended status for a service, or
                          enumerates the status for types of services.
          start-----------Starts a service.
          pause-----------Sends a PAUSE control request to a service.
          interrogate-----Sends an INTERROGATE control request to a service.
          continue--------Sends a CONTINUE control request to a service.
          stop------------Sends a STOP request to a service.
          config----------Changes the configuration of a service (persistant).
          description-----Changes the description of a service.
          failure---------Changes the actions taken by a service upon failure.
          qc--------------Queries the configuration information for a service.
          qdescription----Queries the description for a service.
          qfailure--------Queries the actions taken by a service upon failure.
          delete----------Deletes a service (from the registry).
          create----------Creates a service. (adds it to the registry).
          control---------Sends a control to a service.
          sdshow----------Displays a service's security descriptor.
          sdset-----------Sets a service's security descriptor.
          GetDisplayName--Gets the DisplayName for a service.
          GetKeyName------Gets the ServiceKeyName for a service.
          EnumDepend------Enumerates Service Dependencies.

        The following commands don't require a service name:
        sc   

See also http://commandwindows.com/sc.htm


SCHTASKS
Create, delete, edit, list, start or stop a scheduled task. Works on local or remote computers.

Syntax:
   SCHTASKS /Create [Connect_Options] create_options

   SCHTASKS /Delete [Connect_Options] /TN taskname [/F]

   SCHTASKS /Query  [Connect_Options] [/FO format] [/NH] [/V]

   SCHTASKS /Run [Connect_Options] /TN taskname
   SCHTASKS /End [Connect_Options] /TN taskname

   SCHTASKS /Change [Connect_Options] {[/RU username] [/RP password] [/TR taskrun]} /TN taskname
Connect_Options:
/S system #remote system (default is local)
[/U username [/P password]]#submit job under this name

Create_Options:
[/RU username [/RP password]]#run job under this name
/SC schedule [/MO modifier] #When to run, see below
[/D day] #day = MON,TUE,WED,THU,FRI,SAT,SUN
[/M months] #month=JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC.
[/I idletime] #1 - 999 minutes (ONIDLE task only)
/TN taskname /TR taskrun #Name and pathname for task
/ST starttime #HH:MM:SS (24 hour)
[/SD startdate] [/ED enddate]#start and end date "dd/mm/yyyy"

Options:
/F Force delete, ignore warnings even if the task is currently runnning.
/FO formatOutput format: TABLE, LIST, CSV
/NH No header
/V Verbose output

Notes:
For MONTHLY schedules give the DAY as a number 1 - 31 (default=1)

To prompt for the password, specify /RP * or /RP none

The User Account under which the Schedule service runs may require specific file access permissions, user permissions and drive mappings.

For the system account, /RU username can be written as "", "NT AUTHORITY\SYSTEM" or "SYSTEM", a Password is not required.

/SC schedule The schedule frequency.
Valid schedules: MINUTE,HOURLY,DAILY,WEEKLY,MONTHLY, ONCE,ONSTART,ONLOGON,ONIDLE.

/MO modifiers allow finer control:
MINUTE: 1 - 1439 minutes.
HOURLY: 1 - 23 hours.
DAILY: 1 - 365 days.
WEEKLY: 1 - 52 weeks.
ONCE: No modifiers.
ONSTART: No modifiers.
ONLOGON: No modifiers.
ONIDLE: No modifiers.
MONTHLY: 1 - 12, or FIRST, SECOND, THIRD, FOURTH, LAST, LASTDAY.

Examples:

Create a task to run at 11 pm every weekday
SCHTASKS /Create /SC weekly /D MON,TUE,WED,THU,FRI /TN MyDailyBackup /ST 23:00:00 /TR c:\backup.cmd /RU MyDomain\MyLogin /RP MyPassword

Now delete the task:
SCHTASKS /Delete /TN "MyDailyBackup" /f

Create a daily task to run a script at 5 pm:
SCHTASKS /create /tn "My Script" /tr "\"c:\my folder\script.cmd\" arguments" /sc daily /sd 12/29/2008 /st 17:00

Task Scheduler options are stored in the registry
HKLM\SOFTWARE\Microsoft\SchedulingAgent\

Related:
Q823093 - Scheduled task does not run when the Path contains a space
Powershell: To schedule a PS task call Powershell.exe
Equivalent bash command (linux): crontab - Schedule a command to run at a later time

Source: http://www.ss64.com/nt/schtasks.html