Sign in to follow this  
Followers 0
slightly_abnormal

Open A Folder Using A Variable?

9 posts in this topic

How do I run a folder, using a variable e.g

Opt("ExpandEnvStrings", 1)

$var2 = "notepad.exe"
run($var2)

$var1 = "%appdata%"
run($var1)

$var3 = "c:\"
run($var3)

I've tried the _rundos, and the run(@comspec, but i think they were totally off

this itself

$var2 = "notepad.exe"
run($var2)
works without a hitch but folders are another thing.. :)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

run("explorer.exe c:\")

or using variables:

run("explorer.exe " & $myvar)

hope that helps

:)

Edited by CHRIS95219

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

it didn't work :)

Opt("ExpandEnvStrings", 1)

$var2 = "notepad.exe"
run($var2)

$var1 = "%appdata%"
run("explorer.exe" & $var1)

$var2 = "c:\"
run("explorer.exe" & $var2)
Edited by slightly_abnormal

Share this post


Link to post
Share on other sites

"explorer.exe " and NOT "explorer.exe" ( you forgot the space! :) )

Opt("ExpandEnvStrings", 1)

$var2 = "notepad.exe"
run($var2)

$var1 = "%appdata%"
run("explorer.exe " & $var1)

$var2 = "c:\"
run("explorer.exe " & $var2)

Share this post


Link to post
Share on other sites

ahh i see.. :) thanks for the help guys

Share this post


Link to post
Share on other sites

Alternatively you can use Run (@ComSpec & " /c start C:\").

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Alternatively you can use Run (@ComSpec & " /c start C:\").

oops.. how can i avoid the security dialog when I run a shortcut?

Opt("ExpandEnvStrings", 1)
$var2 = "notepad.lnk"
run("explorer.exe " & $var2)
Edited by slightly_abnormal

Share this post


Link to post
Share on other sites

oops.. how can i avoid the security dialog when I run a shortcut?

Opt("ExpandEnvStrings", 1)
$var2 = "notepad.lnk"
run("explorer.exe " & $var2)
Run (@ComSpec & ' /c "' & $var2 & '"') ; added surrounding quotes just in case there's a space.

Share this post


Link to post
Share on other sites

Run (@ComSpec & ' /c "' & $var2 & '"') ; added surrounding quotes just in case there's a space.

cool, thanks :)

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  
Followers 0