I have to create a script which updates a system environment variable (based on a command line parameter) before launching a program.
In Windows 7, updating the system environment variable is denied. I would like to perform a privilege elevation for just the setting of the env. var. But run the program as a normal user.
How to do it?
Note: I've tried the following solution:
Using 2 scripts:
- 1 master which get all information from command line, which call the slave script to change the system env. var., and which finally launch the program
- 1 slave script that update the system env. var.
- the master script tries to call the slave script using privilege elevation, but that does not work
I've try 2 solutions for the privilage elevation:
- Using the "runas /User:Administrator ..." command but it ask for the Administrator password: Fail
- Using the "ShellExecute ...., "runas"" command but it tells me that my script is not an application: Fail