Computing.Net > Forums > Programming > Create DOS variable - VBS

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

Reply to Message Icon

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.



Sponsored Link
Ads by Google

Response Number 1
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.)


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Create DOS variable - VBS

Creating a variable from a txt file www.computing.net/answers/programming/creating-a-variable-from-a-txt-file/16486.html

strip file name to variable DOS www.computing.net/answers/programming/strip-file-name-to-variable-dos/17111.html

winpe - sysprep - vbs help www.computing.net/answers/programming/winpe-sysprep-vbs-help/17696.html