How do I run a program in Windows 7 with a temporary set of variables?

I need to run a program with a temporary custom set of environment variables in Windows 7.
I created a script to set my variables and called it start.cmd
I ran start.cmd as administrator, but when I run 'set', my original environment variables display.
How can I invoke/run my program with this temporary set of variables?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

if you use the script to set the existing environment variables to new values (including to make them empty) before you invoke a program, the program would inherit the new values rather than the environment variables defined in system settings.

YvetteAuthor Commented:
Hi Sara,
Thanks for the reply. Which command can I run to display the current environment values? It looks like 'set' just lists the system values?
no, set command without options lists all environment variables currently existing. try

set ABCXYZ="some value"
REM try changing system drive from C: to D:
set > allvar.txt

then type the allvar.txt or open it in an editor.

note, that = must be concatenated without spaces and that text values either may have no space or must be quoted by "".

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

YvetteAuthor Commented:
Ok, I have done some testing.
If I set eviron values on the command line one by one, they are accepted in the current values list.
However, I need to configure ALL my values to new ones or unset them. That will give me a custom set of values for the program I need to run.
So I need to set and unset all my values at once. I tried to do this with a script. The script runs, but does not change the values.
How can I change all my environment values to a new set of values at once?
if you invoke the script by 'call' the changed environment variables will be available in the calling script as well.

x.bat :
@echo off
call y.bat
echo %ABC%

Open in new window

y.bat :
@echo off

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
YvetteAuthor Commented:
I called my y.bat from my x.bat.
The y.bat should launch a GUI installer program. The GUI does not launch and when I check with Task Manager, the program I wish to run with the custom set of variables does not run.
Please advise
YvetteAuthor Commented:
Hi Sara
I replaced the 'call y.bat' with 'y.bat' and the y.bat launched.
So I am sorted.
Thank you so much for your help,
YvetteAuthor Commented:
Sara stuck with me as I struggled through foreign territory.
I am very grateful.
fyi: calling a batch file let the called script run as it would be withing the calling script. if you want to launch an application from thhere you have to use start command where you have some options whether you want to wait for the launched application to exit before going on or not. if you omit the 'call' you start a new environment which inherits the environment of the caller but cannot give back. also the calling script would not wait for the called script to end.

good luck.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.