SyMenu Forum

SyMenu

 

HomeTroubleshooting & Bug Reports

If you found a bug post here your report.

Can't seem to launch vscode elevated... Messages in this topic - RSS

sffdb8
sffdb8
Posts: 18


29 days ago
sffdb8
sffdb8
Posts: 18
Although I have "Run elevated" checked in item definition, vscode will not launch elevated...

Seems specific to vscode as "Run elevated" works fine on other items.

Any workarounds?
link
Gianluca
Gianluca
Administrator
Posts: 993


26 days ago
Gianluca
Gianluca
Administrator
Posts: 993
The reason is quite complex.

In the past I did a lot of researches about the program execution in elevated mode and I discovered this strange Windows behavior.


When I execute a program I use a C# object called ProcessStartInfo.
ProcessStartInfo has a property called UseShellExecute that allows the execution in elevated mode (true -> elevated|false -> normal). Well you need to set another property along with UseShellExecute but we don't care now.

But ProcessStartInfo is the same object I use to manipulate the environment variables for that single execution. In fact I can't modify the environment variable system wide but I sometimes I need to change them only for the program in execution. The ProcessStartInfo property for this magic is called EnvironmentVariables.

The two properties can't be manipulated at the same time. So if you need an elevated execution you have to leave the EnvVar unchanged or vice versa.


VS Code is subject to a manipulation of its EnvVar. In fact if you go to SyMenu program configuration form and find out VS Code, you'll see that the "Enable advanced parameters" is checked and an EnvVar is redefined (APPDATA=.\).
What's the point for this variable? It's useful to tell VS Code to save its configuration/last opened tab/last opened project/backup/add in/ and a ton of other settings, in a folder called Code inside the program root and not in your C:\Users[user]\AppData\Roaming\ folder.

The workaround for you is really easy: remove the check from "Enable advanced parameters" and your VS Code will run in elevated mode when you need it. But remember that your settings folder will be saved in the real AppData\Roaming folder from then on.
link



UGMFree.NET ©2002-2020
By Gianluca Negrelli - Contact me