SET

RECENT NEWS

12/18/2015 - Hello! We're excited to announce that Mental Works Computing Software will soon be featuring

12/11/2015 - We're going to announce Dr.Batcher 3.0 Alpha with batch files debugger support soon. If you want to start...

News history...

TESTIMONIALS

Rob van der Woude:
"Mental Works Computing Software has created a nice tool for...

Andrew Jaritsyn:
“I used to write batch files with the help of Notepad, but...

Steve H.:
“This tool helped me to write some batch files in a couple...

More...

SET

Sets, changes or removes command line environment variables.

Syntax:

SET [Variable=[String]]

SET [/p] Variable=[PromptString]

SET /a Variable=Expression

Variable – the name of the environment variable to be set or modified.

String – value of the specified variable.

/p – makes SET command to prompt user for the value of Variable.

PromptString – prompt message text.

/a – makes SET command to evaluate the Variable numeric value from the specified expression.

Expression – expression to evaluate.

Usage:

If you use SET command without any parameters, current environment settings will be displayed.

All command line environment variables are strings by default.

To use special character to a variable (<,>,|,&,^), you should first add ^ character before it.

To delete a variable, you should just assign it no value.

For evaluating expressions with SET, you can use the following operators:

You can use all operators in C-style like +=, -= etc.

To use hexadecimal numbers, start them with 0x, to use octal numbers, start them with 0.

Examples:

Simple assignment:

SET Myvar=Some_value^&Another_part^^of_value

Assignment prompt:

SET /p Myvar=Set the variable

Expression:

SET /a Myvar=2*(2+2)

 

Subscribe batch files programming newsletter (no spam):

Subscribe

Unsubscribe