| 1. |
Solve : DOS environment variable? |
|
Answer» I try to store a file sequence NUMBER in an ENVIRONMENT variable. Using set only creates an environment variable for the current session, but you can use the setx command to create persistent variables. Type setx /? to see the documentation. example: setx filesequence a You need to start a new command session to see the new variable Note that to set the variable to a null value you can do setx filesequence "" but the registry entry will still be there. To completely remove it use the enviroment variables GUI. Something you should note: Your script that you showed contains too many spaces in the SET command. This command: SET filesequence = a does not create a variable referred to by %filesequence% which expands to "a". It creates a variable referred to by %filesequence % which expands to " a". (The quotes are not part of the values, I included them to show the effect of the leading SPACE) You need: SET filesequence=a See? No spaces. In the SET command syntax every character before the = character is part of the variable name and every character after the = is part of the variable value. This includes spaces. In fact this applies generally, e.g. in IF comparisons. thanks very much for the information. However, when I tried SETX, I got the message N:\>setx fileseq=1 'SETX' is not recognized as an internal or external command, operable program or batch file. I am running C:\WINDOWS\system32\command.com Do I need to turn on anything? thanks.What operating system are you running? If Windows 2000 or after, why aren't you using cmd.exe? Hi, I am running Window XP professional 2002, service pack 3. The same unrecognised SETX return when I execute it through CMD.EXE thanks.Quote from: edwin.fung on February 22, 2011, 11:13:03 AM Hi, I am running Window XP professional 2002, service pack 3. The same unrecognised SETX return when I execute it through CMD.EXE 1. get it here http://www.microsoft.com/downloads/en/confirmation.aspx?FamilyID=dc2d3339-8f36-4fba-a406-2a2a2ad7208c 2. You used the wrong syntax Quote However, when I tried SETX, I got the message You should use setx fileseq 1 No equals sign. I showed you this above. thanks a lot! It works! Quote from: edwin.fung on February 24, 2011, 12:18:47 PM It works! That is GOOD news! |
|