Jump to content

Simple script to run exe from root of current drive.


Recommended Posts

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

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

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...