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: 20


13/06/2020
sffdb8
sffdb8
Posts: 20
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: 1274


15/06/2020
Gianluca
Gianluca
Administrator
Posts: 1274
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
sffdb8
sffdb8
Posts: 20


12/12/2020
sffdb8
sffdb8
Posts: 20
Thanks for your very detailed explanation!

btw - For some reason it seems I didn't receive a notification that you responded (seems I'm subscribed because it says "stop watching this topic" up top...
(and I don't have a spam folder). just an FYI in case others share the same observation
link
Gianluca
Gianluca
Administrator
Posts: 1274


14/12/2020
Gianluca
Gianluca
Administrator
Posts: 1274
Well I had the same problem for a while but I think now it's gone.

Please tell me if you receive the notification for this one.
link
sffdb8
sffdb8
Posts: 20


14/12/2020
sffdb8
sffdb8
Posts: 20
Thanks - got the notification.
link



UGMFree © 2002-2024
PayPal BTC TON