Jump to content

Changing Drive Letter Automatically


Recommended Posts

I know this has been discussed (infact, I've searched for a few hours), but the solutions offered were either partial or didn't work with my needs. Basically, I'm scripting a GUI Menu that will autoexec when a USB Flashdrive is put in (it resides on the USB Flashdrive). This menu has links to programs on the Flashdrive, these programs/links often require a drive letter assignment that is static. So I always assign drive "P" (for Portable). Which leads me to the script ...

I'm looking for something that when the program is initially ran, will check to see if A) "P" is available as a drive letter, and :) if "P" is already assigned to the current USB key (program resides on USB key). If P is available and is not assigned, it will then change the current drive letter (for USB drive) to letter "P:". I thought about having it run just drive-management so I could manually change it, but that sorta defies the whole point of the script.

Any ideas? Maybe I missed a few threads. There was one where the guy had the exact thing, but only partial code was up. I don't have any code examples because I don't even know where to begin on this, it's a tad over my head ;)

Edited by kylek29
Link to comment
Share on other sites

I know this has been discussed (infact, I've searched for a few hours), but the solutions offered were either partial or didn't work with my needs. Basically, I'm scripting a GUI Menu that will autoexec when a USB Flashdrive is put in (it resides on the USB Flashdrive). This menu has links to programs on the Flashdrive, these programs/links often require a drive letter assignment that is static. So I always assign drive "P" (for Portable). Which leads me to the script ...

I'm looking for something that when the program is initially ran, will check to see if A) "P" is available as a drive letter, and :) if "P" is already assigned to the current USB key (program resides on USB key). If P is available and is not assigned, it will then change the current drive letter (for USB drive) to letter "P:". I thought about having it run just drive-management so I could manually change it, but that sorta defies the whole point of the script.

Any ideas? Maybe I missed a few threads. There was one where the guy had the exact thing, but only partial code was up. I don't have any code examples because I don't even know where to begin on this, it's a tad over my head ;)

Is there a reason for you not to use relative paths (instead of absolute paths)? If it's a matter of executing applications on your flash drive, I'd just pop your GUI menu executable into the root of the drive, then for each of your programs you want to launch, just use @ScriptDir\Program folder\program.exe

Edited by Monamo

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
Share on other sites

Is there a reason for you not to use relative paths (instead of absolute paths)? If it's a matter of executing applications on your flash drive, I'd just pop your GUI menu executable into the root of the drive, then for each of your programs you want to launch, just use @ScriptDir\Program folder\program.exe

Some programs have configurations that require a static path (old programs) for other items it calls. Plus, I want it to be compatible with shortcuts on the desktop. For example, at work. I have the initial launch of some programs looking in the directories below it with @ScriptDir, so I can launch things fine even if it is assigned "E:".

Another example would be WMP. One thing I use the Flashdrive for at work is to store music. Windows Media Player (on the PC) references the "P:\Music" for the library, as do other programs (with differing files). In the long run, it's just easier to have it always assigned to "P" if available.

Edited by kylek29
Link to comment
Share on other sites

Easily got it to map P: to a drive. However I still can't figure out how to get it to pull the current drive - this will change on each PC I enter the Flashdrive into - still a little n00bish on some of this stuff. I was *hoping* it'd be as easy as run("subst p: @ScriptDir\") ...

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