"Run" issue in virtual desktop Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
JustinNL
Posts: 28
Joined: 01 Sep 2020, 13:22

"Run" issue in virtual desktop

Post by JustinNL » 27 Jan 2022, 07:56

Dear all,

I have an issue with the Run command.
I am working on a virtual desktop at work and want to start a program.

Usually the path is something like C:\program files\my_program\my_program.exe

However, in the virtual desktop, the absolute path to my progam is %AppVPackagePathEPD%\Root\my_program\my_program.exe
When I run the following code I get an error that the target cannot be found. Probably AHK treats %AppVPackagePathEPD% as a variable.

Code: Select all

^+x::Run, %AppVPackagePathEPD%\Root\my_program\my_program.exe

I've also tried the following but it still gets an error

Code: Select all

^+x::Run, `%AppVPackagePathEPD`%\Root\my_program\my_program.exe
When I run the exact string (%AppVPackagePathEPD%\Root\my_program\my_program.exe) in the normal Run dialogue from the start menu it works fine.
I also tried doing it through %ComSpec% but this is disabled by our IT guys.

Do you have any suggestions? Or is there a way to first resolve %AppVPackackagePathED% to a normal path in AHK and then use this path in the Run command?

Hopefully I've worded the question clearly,
Thanks in advance for your suggestions!

Justin

RussF
Posts: 1237
Joined: 05 Aug 2021, 06:36

Re: "Run" issue in virtual desktop  Topic is solved

Post by RussF » 27 Jan 2022, 08:04

AppVPackagePathEPD is a Windows environment variable, not an AHK variable. That's why the Windows Run command works, but AHK's does not.

See https://www.autohotkey.com/docs/Concepts.htm#environment-variables for ways to access env vars.

Russ

User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: "Run" issue in virtual desktop

Post by boiler » 27 Jan 2022, 08:27

To that point, if your script has #NoEnv at the top of it, you could remove that and allow that environmental variable to take on its value.

JustinNL
Posts: 28
Joined: 01 Sep 2020, 13:22

Re: "Run" issue in virtual desktop

Post by JustinNL » 28 Jan 2022, 14:48

Thanks! I wasn’t aware that windows also uses variables with %%. I added an ‘EnvGet’ at the top of my script, this fixed the issue!

Best, Justin

RussF
Posts: 1237
Joined: 05 Aug 2021, 06:36

Re: "Run" issue in virtual desktop

Post by RussF » 28 Jan 2022, 16:18

Actually, the environment variables go all the way back to the DOS era (yeah, ok, I'm dating myself). If you open a command window, Win-R (or select "Run" from the start button) and type "Cmd", you'll get the DOS command prompt. Type "set" (no quotes) and press Enter. You will see all the environment variables for your current session. Notice no % signs, however, the way you substitute the value of any environment variable within a Run command is to surround the variable name with %'s. While you're there, type "echo %temp%" (again, no quotes" and you will see the path to Windows' temp folder.

Russ

Post Reply

Return to “Ask for Help (v1)”