I’m trying to write a Windows batch file that kicks off a setup program for internal users at my company. There is a link to the batch file on our intranet. If you click the link (at least on IE9, which I must support) then it asks if you want to Run or Save the file. Most users click Run, and the batch file executes as a child process of IE, inheriting its environment variables. This is where my problem arises.
If the browser has been open for a while, it’s possible that a (user or system level) environment variable has been set on the user’s PC after the browser was launched, so the batch file doesn’t see that variable, and I need it to.
I want to find a way to make sure the batch file always runs with a fresh environment.
This works
rem bootstrap batch file
explorer the_real_batch_file.bat
because Explorer.exe is alert to user and system environment variable changes, but this doesn’t
rem bootstrap batch file
explorer the_real_batch_file.bat some_param
The some_param confuses Windows Explorer (and it just launches a new Windows Explorer window). I need to be able to pass parameters to the ‘real’ batch file, so this is a show-stopper.
Can anyone see a way around this?
I ended up simplifying my problem slightly. I am now able to run
start explorer my_batch_file(without arguments to the batch file) because I generate a bespoke intermediate batch file in%TEMP%containing the arguments I need.So I do this:
And inside
temp_batch_file.batI haveThis seems to work fine.