Hi all, forum newbie here. I'm an old AIX/Linux guy but my wife has a side business that I need to support so I'm in the DOS world...
I thought I was trying to do something extremely simple. Either that's not the case or I'm just flat being dense....
In a .bat/.cmd file run from the command prompt, I just want to do:
If $Variable3 is NULL then set Variable3=0
Then printing out Variable_3 (just as a sanity check) I've tried every syntax I can find and think of, as well as a few others.
I'm just at a loss. It seems like it should be a straight forward "if then else" statement but....
Anyone set me straight?
Steve
Setting variable problem in .bat or .cmd script ?
Moderator: DosItHelp
-
- Posts: 1
- Joined: 10 Sep 2020 15:20
Re: Setting variable problem in .bat or .cmd script ?
You can see the proper syntax for a command by typing the command name followed by a question mark from the cmd prompt.
But it is usually a lot easier just to reference Microsoft's documentation but I usually use SS64.
https://ss64.com/nt/
or
Code: Select all
if /?
https://ss64.com/nt/
Code: Select all
IF NOT DEFINED variable3 set "variable3=0"
echo %variable3%
Code: Select all
IF "%variable3%"=="" set "variable3=0"
echo %variable3%