Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Create DOS variable - VBS
Name: astroraptor Date: August 30, 2008 at 09:17:25 Pacific OS: Windows XP Pro CPU/Ram: 2.33GHz/3072MB Product: Lenovo ThinkCentre
Comment:
How can I create a DOS variable with a VB script variable? One that will only exist during while the program is running.
Name: Razor2.3 Date: August 31, 2008 at 19:43:58 Pacific
Reply:
You cannot run a VBScript to modify an existing environment. If you wish to pass a value to the starting CMD, run your script from CSCRIPT.EXE, and pass your number as the ERRORLEVEL (via: WScript.Quit <number>).
0
Response Number 2
Name: astroraptor Date: September 1, 2008 at 05:01:30 Pacific
Reply:
Actually you can, I've found the problem seems to be that when you create the environment it gets deleted once the application closes. When I save a variable to the "USER" environment it only appears once you exit and start the command-line interface again and of course gets saved permanently. Until you have it deleted. I really don't have a clue other than redirecting the output to a file which the batch file picks up on and creates a variable from. Which to me, isn't exactly all that safe.
0
Response Number 3
Name: Razor2.3 Date: September 1, 2008 at 14:15:33 Pacific
Reply:
Actually you can, I've found the problem seems to be that when you create the environment it gets deleted once the application closes. Alright, you got me. you can't modify an existing environment that's not your own (you = any application). Any child application you spawn will inherit your modified environment, but your parent application's environment will remain untouched.
0
Response Number 4
Name: astroraptor Date: September 1, 2008 at 16:11:40 Pacific
Reply:
So my "solution" is the only one unless I do the entire project in VBS?
0
Response Number 5
Name: Razor2.3 Date: September 1, 2008 at 17:35:02 Pacific
Reply:
Yeah. The only thing returned to the parent process will be the ERRORLEVEL, returned by WScript.Quit.
Or you can have your script launch a Command Script, and THAT will have your modified environment. (Assuming you modify the "PROCESS" environment.)
Summary: Hi I want to make a batch file that creates variables by parsing a .txt file made from a "dir /b /n > dirlist.txt" command. Each line in the .txt file is a single filename. I need each line/filename ...
Summary: Hi there, may I borrow your brains please? I run a radio station using winamp, wacommand, gawk, batch files and task scheduler. Mainly from batch files. Anyways could I please have help, I just need t...
Summary: im trying to write a script that can run within winpe 2.0. to help with changing the computer name to the dell service tag, within sysprep after imaging. i thinking that i should be able to grab the d...