Sign in to follow this  
Followers 0
pjw73nh

Simple script to run exe from root of current drive.

4 posts in this topic

Greetings,

I have a program that requires a parameter after the exe in order to run.

It is a small app that I keep on a thumbdrive. If I want to open the app I have to go the the drive letter of the thumb drive (which changes depending on what machine I am using), then I have to go to the keepass folder, then dbl click keepass.exe, then click open, navigate to the correct DB and then open it.

If I put it all in one line it would look like this : M:\KEEPASS\KEEPASS.EXE DATABASE.KDB This works fine from the START | RUN box.

Here is the script (loose term) so far:

$Z = @ScriptDir
Run($z & "\" & "keepass.exe" & " " & "Database.kdb")

This works fine, but I still have to navigate the folder that holds the app and the script. IE M:\KEEPASS. I would like to put the script in the root of the thumb drive and have the script navigate to the correct folder to make it easier to open the app. This way, no matter what drive letter the thumbdrive gets when inserted into any computer, I would just have to click on the script in the root, and it would run the app from \keepass with the correct db as the parameter.

I can't find a macro that returns only the "current drive". If I could find the current drive, I may be able to do an *IfExist current-drive\keepass* then..... take this action etc...

@WorkingDir returns the whole path. Drive and folder...

Or am I over complicating this?

Any help would be much appreciated. Thanks

Share this post


Link to post
Share on other sites



If your running the script from the root then just use the @scriptdir still and move the dir over to the path...

$Z = @ScriptDir
Run($z & "keepass\keepass.exe" & " " & "Database.kdb")

Share this post


Link to post
Share on other sites

If your running the script from the root then just use the @scriptdir still and move the dir over to the path...

$Z = @ScriptDir
Run($z & "keepass\keepass.exe" & " " & "Database.kdb")

Thanks. I guess I wasn't as clear as I should've been. But it worked out anyway. I just made two scripts. I meant to say I wanted to put the script in BOTH places. The root and the folder and have it run. But just as well to have two scripts in two places. Thanks for the help.

Share this post


Link to post
Share on other sites

@ScriptDir is the full path... If you only want the drive letter, just take the first two characters.

Run(StringLeft(@ScriptDir, 2) & "\keepass\keepass.exe Database.kdb")


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

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