Link to home
Start Free TrialLog in
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)Flag for United States of America

asked on

Specifying wscript Command as a Context Menu Command with Environment Variable

I am trying to specify a wscript command as a context menu item. I am having trouble using an environment variable in the command.

What I have:

wscript.exe "%USERPROFILE%\Documents\Scripts\Script.vbs" "%1"

Produces this error from wscript:

"Can not find the script file "C:\Users\User Name\Documents\Scripts\USERPROFILE\Documents\Scripts\Script.vbs"

WTF? This substitution makes no sense.

If I run the same command in DOS (with the %1 already substituted,) it works just peachy.

Any ideas?

Kevin
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

ASKER

Here are the registry entries:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell]

[HKEY_CLASSES_ROOT\*\shell\Run My Script]

[HKEY_CLASSES_ROOT\*\shell\Run My Script\command]
@="wscript.exe \"%USERPROFILE%\\Documents\\Scripts\\Script.vbs\" \"%1\""

Kevin
ASKER CERTIFIED SOLUTION
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial