ID:156847
 
I can't seem to get any environment variables to work. I may be missing something.

I expect the following code to open an explorer window to the system drive.
   shell("%SYSTEMDRIVE%")


ts
meh... using just the environment variable to the system root may not work due to "shell expects to find executable files " but that doesn't answer the question about environment variables and if they work or not.

ts
I got it working with some help from a note left in the reference documentation for shell(). I was able to force the console window to stay open and see where I was going wrong. Thanks to whoever put that in there.

I just needed some additional double quotes.

shell("\"\"%PROGRAMFILES%\\MyApplication\\MyApp.exe\"\"")


ts
In response to Tsfreaks
I have to take that back. That only works if you pass in cmd /C. I'm still working on the proper syntax which doesn't require running cmd first.

shell("cmd /C \"\"%PROGRAMFILES%\\MyApplication\\MyApp.exe\"\"")


My expectation is that the following example should work bit it doesn't so I assume that I am missing needed double quotes. I'm also trying to pass in an argument as well.

    shell("\"\"%PROGRAMFILES%\\MyApplication\\MyApp.exe [myArg]\"\"")


ts
In response to Tsfreaks
This should work...
shell("\"\"%PROGRAMFILES%\\MyApplication\\MyApp.exe\" [myArg]\"")


Because this works...
shell("cmd /C \"\"%PROGRAMFILES%\\MyApplication\\MyApp.exe\" [myArg]\"")


but it doesn't... and I'm stuck...

ts
In response to Tsfreaks
This is the best that I can do for now but it still shows the console window every time I execute it (which I don't want).

I can't figure out the syntax without using cmd /C.

shell("cmd /C \"\"%PROGRAMFILES%\\MyApplication\\MyApp.exe\" [myArg]\"")


I've made a wonderful mess of this post but if you are capable and have made it this far, I could still use a hand solving this.

Thanks,
ts
In response to Tsfreaks
I believe shell is set to call files directly... and since you want to use an environmental variable, it must go through the command prompt.
In response to Leur
Well... that makes sense...

Thanks,
ts