Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

Windows Server 2008 Server Core : Creating Batch Files (part 4) - Using the Prompt Command

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
4/25/2012 4:15:20 PM

9. Using the Pause Command

The Pause command stops batch file execution to give the user time to react to a particular need. For example, if you need the user to change media to complete the batch file, you could use the Echo command to tell the user about the need and then use the Pause command to tell the user to press any key when the media exchange is complete.

10. Using the Prompt Command

The Prompt command changes the command line prompt. For example, instead of the usual drive letter, directory, and greater than sign, you could use the time and date as a prompt. In fact, the prompt can contain any text you want. To change the prompt, simply type Prompt, followed by the text you want to display, and press Enter. The following list defines the special characters you can use as part of the command prompt.

$A

& (Ampersand)

$B

| (Pipe)

$C

( (Left parenthesis)

$D

Current date

$E

Escape code (ASCII code 27)

$F

) (Right parenthesis)

$G

> (Greater than sign)

$H

Backspace (erases previous character)

$L

< (Less than sign)

$N

Current drive

$P

Current drive and path

$Q

= (Equals sign)

$S

(Space)

$T

Current time

$V

Windows version number

$_

Carriage return and linefeed

$$

$ (Dollar sign)

You can access two additional formatting characters when you have command extensions enabled. The following list describes these two additions.

$+

Displays zero or more plus sign characters depending on the depth of the PushD utility directory stack. The display shows one character for each level you've pushed onto the stack.

$M

Displays the remote name associated with the current drive letter. If this is a local drive, then the system displays an empty string.

11. Using the Rem Command

The Rem (Remark) command lets you add comments to your batch files. Given that batch files often use difficult to read coding sequences and that you'll probably want to modify them at some point, lots of comments are advisable. In fact, you'll want to add at least one comment for each complex line of code in your batch file. Many people have lost use of interesting and helpful batch files because they contain complex code that becomes unreadable after the initial writer forgets what the code means.

12. Using the Shift Command

A batch file supports a maximum of 10 command line arguments numbered %0 through %9. However, you might run into situations where you need more than 10 command line arguments. The Shift command can help you shift in these additional arguments. The new arguments replace existing arguments. In fact, all of the arguments are shifted one position, so the argument in %1 now appears in %0. Unfortunately, the argument in %0 is shifted out so that it's no longer accessible.

You can retain some older arguments in memory when you have command extensions enabled. The Shift command will accept a numeric argument that tells where to begin shifting arguments. For example, when the command appears as Shift /2, the values in %0 and %1 are unaffected. However, Shift will shift the arguments starting with %2 so that %2 now contains the value from %3.

13. Using the TimeOut Utility

The TimeOut utility provides a unique feature in that you can tell it to wait for a specified time period no matter what the user does. Consequently, unlike the Choice command, when you tell TimeOut to wait 30 seconds, it waits the entire time period even if the user presses a key. In addition, the TimeOut utility doesn't display a message for the timeout, so you can use this utility where silence is necessary (such as a background task). This command uses the following syntax:

TIMEOUT [/T] timeout [/NOBREAK]
The following list describes each of the command line arguments.

/T
timeout

Specifies the timeout value. The command line switch is optional. You may specify any value from −1 to 99999 seconds. A value of −1 means that the utility waits indefinitely for a key press. The utility won't allow you to combine a value of −1 with the /NOBREAK command line switch since that would effectively lock the system.

/NOBREAK

Prevents the utility from recognizing key presses. The TimeOut utility waits for the specified time period before it exits.

14. Using the WaitFor Utility

The WaitFor utility enables communication between processes. You can send a signal from one application to another. In fact, you can use this feature for signaling between batch files. When using this utility, you start the receiving application first and tell it to wait for the signal. The sender then sends the signal when it's ready. This command uses the following syntax:

Sender Syntax:
WAITFOR [/S system [/U [domain\]user [/P [password]]]] /SI signal

Receiver Syntax:
WAITFOR [/T timeout] signal
The following list describes each of the command line arguments.

/S
system

Specifies the remote system that you want to check. In most cases, you'll also need to supply the /U and the /P command line switches when using this switch.


/U
[domain\]user

Specifies the username on the remote system. This name may not match the username on the local system. You'll need to supply a domain name when working with a domain controller.


/P
[password]

Specifies the password for the given user. You can provide the command line switch without specifying the password on the command line in clear text. The system prompts you for the password. Using this feature can help you maintain the security of passwords used on your system.


/SI

Sends the requested signal across the network.


signal

Specifies the signal to send or receive. The signal is a simple string value such as StartSetup. A system can wait for multiple unique signals. The maximum signal name length is 255 characters. You may use a–z, A–Z, 0–9, and any ASCII character code in the range 128–255 for the string value. The string value can't contain special characters or spaces.


/T timeout

Defines the amount of time to wait for the signal. You can specify any value from 1 to 99,999 seconds. The default setting waits an infinite amount of time.

Other -----------------
- Microsoft Content Management Server : Using SharePoint to Display MCMS Content (part 3) - The MCMS Pages Waiting for Approval Web Part
- Microsoft Content Management Server : Using SharePoint to Display MCMS Content (part 2) - A Custom View for the MCMS Page Listing Web Part
- Microsoft Content Management Server : Using SharePoint to Display MCMS Content (part 1) - Installing the MCMS Connector Web Parts & MCMS Page Listing Web Part
- Active Directory Domain Services 2008 : Create an Organizational Unit
- Active Directory Domain Services 2008 : Modify a Computer Object’s Managed By Properties, Modify a Computer Object’s Protection from Deletion & Modify a Computer Object’s Custom Attributes
- Exchange Server 2010 : Monitoring Events, Services, Servers, and Resource Usage (part 2) - Monitoring Exchange Messaging Components & Using Performance Alerting
- Exchange Server 2010 : Monitoring Events, Services, Servers, and Resource Usage (part 1) - Viewing Events & Managing Essential Services
- Windows Server Enterprise Administration : Managing Software Update Compliance (part 2) - Planning and Deploying Security Baselines
- Windows Server Enterprise Administration : Managing Software Update Compliance (part 1) - Microsoft Baseline Security Analyzer
- Windows Server 2003 : Command-Line Utilities - SCWCMD & MBSACLI
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server