Jump to content

Use explorer.exe to open an environmental variable path?


Recommended Posts

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!

Link to comment
Share on other sites

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"))

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...