Jump to content
Sign in to follow this  
Delebre

Use explorer.exe to open an environmental variable path?

Recommended Posts

Delebre

I have a quick script that I wrote, that I was hoping to make future compatible by using environmental variables in Windows 7. 

Here is my script:

Run("Explorer.exe " & "C:\Users\TheDude\Shortcuts") 
WinWaitActive("Shortcuts")
Send("+!0")

I have an environmental variable set in Windows. It's: %Shortcuts%

However, when I tried this:

Run("Explorer.exe " & "%Shortcuts%") 
WinWaitActive("Shortcuts")
Send("+!0")

It does not work. So I'm clearly missing something.

One more thing, I can't make this work without adding that space between Explorer.exe and the second " that you can see in both my scripts. If I take out the space it doesn't work period. 

Any clarification would be helpful. Thanks!

Share this post


Link to post
Share on other sites
orbs

hello Delebre, welcome to AutoIt and to the forum!

in addition to using EnvGet() as jdelaney said, be aware that explorer.exe is very "special" when it comes to command-line switches.

take a close look here:

http://support.microsoft.com/kb/314853

you'll end-up with something like this:

Run("Explorer.exe /n," & EnvGet("Shortcuts"))

b.t.w if you just want to open a folder, you do not need to call explorer.exe at all:

ShellExecute(EnvGet("Shortcuts"))

Share this post


Link to post
Share on other sites
Delebre

Hey guys! Thank you for getting back to me so quickly! I'm blown away :)

I will try that out right now.  :zorro:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×