Jump to content

USB Removable Drive


Recommended Posts

I have a bunch of scripts on a usb drive that I run on differnet computers. Problem is that each computer assigns my flashdrive a different letter. Is there a way of using % % around REMOVABLE DRIVE to equalize this for every computer I use.

I did a search and found a great little script by a member that will find the drive letter:

#include <string.au3>
$usb = DriveGetDrive( "REMOVABLE" )
If NOT @error Then
     For $i = 1 to $usb[0]
$usbdev = RegRead("HKLM\SYSTEM\MountedDevices", "\DosDevices\" & $usb[$i])
$usbrealdev = _HexToString($usbdev)
    If StringInStr ( $usbrealdev, "STORAGE#RemovableMedia#" ) then
     If DriveGetFileSystem ( $usb[$i] ) <> "NTFS" then MsgBox(0,"USB-Drive", $usb[$i])
    Endif
    Next
EndIf

So how do I run a program using this information?

EG:

Run ( '%$usb%\FMEN\RunIt\runit.exe' ) doesn't work

Thanks for any help

Link to comment
Share on other sites

I have a bunch of scripts on a usb drive that I run on differnet computers. Problem is that each computer assigns my flashdrive a different letter. Is there a way of using % % around REMOVABLE DRIVE to equalize this for every computer I use.

I did a search and found a great little script by a member that will find the drive letter:

#include <string.au3>
$usb = DriveGetDrive( "REMOVABLE" )
If NOT @error Then
     For $i = 1 to $usb[0]
$usbdev = RegRead("HKLM\SYSTEM\MountedDevices", "\DosDevices\" & $usb[$i])
$usbrealdev = _HexToString($usbdev)
    If StringInStr ( $usbrealdev, "STORAGE#RemovableMedia#" ) then
     If DriveGetFileSystem ( $usb[$i] ) <> "NTFS" then MsgBox(0,"USB-Drive", $usb[$i])
    Endif
    Next
EndIf

So how do I run a program using this information?

EG:

Run ( '%$usb%\FMEN\RunIt\runit.exe' )    doesn't work

Thanks for any help

<{POST_SNAPBACK}>

check out the macro reference in the help file, you may be able to find an easier way to access the drive that the script is on...
Link to comment
Share on other sites

Are all the scripts on the same drive? And you have a master script that calls other scripts? If so, then in your master script, get it's drive letter like this:

$Drive = StringLeft(@ScriptDir, 1)

Link to comment
Share on other sites

Are all the scripts on the same drive?  And you have a master script that calls other scripts?  If so, then in your master script, get it's drive letter like this:

$Drive = StringLeft(@ScriptDir, 1)

<{POST_SNAPBACK}>

heh, the one time i try to make somebody think for the answer and somebody else gives it away... :)
Link to comment
Share on other sites

#include <string.au3>

$usb = DriveGetDrive( "REMOVABLE")
If Not @error Then
   For $i = 1 To $usb[0]
      $usbdev = RegRead("HKLM\SYSTEM\MountedDevices", "\DosDevices\" & $usb[$i])
      $usbrealdev = _HexToString ($usbdev)
      If StringInStr($usbrealdev, "STORAGE#RemovableMedia#") Then
          $sDeviceLetter = $usb[$i]
         If DriveGetFileSystem( $sDeviceLetter ) <> "NTFS" Then
            ;MsgBox(0, "USB-Drive", $usb[$i])
             Run ( $sDeviceLetter & "\FMEN\RunIt\runit.exe" )
         EndIf
      EndIf
   Next
EndIf

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