Sign in to follow this  
Followers 0
fmen

USB Removable Drive

7 posts in this topic

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

Share this post


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

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
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)

Share this post


Link to post
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... :)

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Terrific stuff you all. I do appreciate the help. I am sure it will work. Thanks.

Share this post


Link to post
Share on other sites

Please, people, no more giving stuff away on the forums. :^)

J


If I am too verbose, just say so. You don't need to run on and on.

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