Shocker Posted October 5, 2014 Share Posted October 5, 2014 Hi there, is it possible that a Prog can ONLY be started from a Mass Storage like USB Stick, external HDD, SD Card whatever? Link to comment Share on other sites More sharing options...
JohnOne Posted October 5, 2014 Share Posted October 5, 2014 I imagine so. Look at DriveGetDrive() and do something with that, and the path to your script. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Shocker Posted October 5, 2014 Author Share Posted October 5, 2014 (edited) Thx for reply! I test DriveGetDrive() for example with >THIS, but he show me a USB HDD as a FIXED Drive... Edited October 5, 2014 by Shocker Link to comment Share on other sites More sharing options...
JohnOne Posted October 5, 2014 Share Posted October 5, 2014 Show the exact code you used. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Shocker Posted October 5, 2014 Author Share Posted October 5, 2014 Have nothing yet... Looking for a "Startup Check" which test, whether used Drive is a Mass Storage or not. Link to comment Share on other sites More sharing options...
JohnOne Posted October 5, 2014 Share Posted October 5, 2014 You gave a link to someone's code that does not work, that's why he posted in help and support. Why did you expect it to work for you? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Shocker Posted October 5, 2014 Author Share Posted October 5, 2014 No, i don't expect that a code work 100% at first time (but sometimes do). I search what i need and test different code snipets, or ask if i don't find right one. Link to comment Share on other sites More sharing options...
JohnOne Posted October 5, 2014 Share Posted October 5, 2014 I think you are not understanding. You wrote this... but he show me a USB HDD as a FIXED Drive Post the exact code you tried to get that. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Shocker Posted October 5, 2014 Author Share Posted October 5, 2014 getdrives() Func getdrives() ; Fill the destination list Local $drives = DriveGetDrive("ALL") If @error == 1 Then MsgBox(0, "Error", "No removeable media found, cannot continue!" & @CRLF & "Please insert a micro SD card or other removeable media to copy to.", 15) ;GUISetState(@SW_SHOW, $mainwindow) GUISetState(@SW_HIDE, $cabswindow) Else For $i = 1 To $drives[0] Local $drive = $i Local $type = DriveGetType($drives[$i] & "") If @error == 1 Then $type = "Error getting drive type" EndIf ConsoleWrite($drives[$i] & "\ " & $type & @CRLF) Next EndIf EndFunc ;==>GetDrives Result... c: Fixed d: Fixed e: Fixed f: CDROM g: CDROM h: Fixed -> is USB HDD i: Removable -> is a USB Stick Link to comment Share on other sites More sharing options...
Spider001 Posted October 5, 2014 Share Posted October 5, 2014 Type of drive to find: "ALL", "CDROM", "REMOVABLE", "FIXED", "NETWORK", "RAMDISK", or "UNKNOWN" use what you need ? Link to comment Share on other sites More sharing options...
jguinch Posted October 5, 2014 Share Posted October 5, 2014 You can use a WMI query to find out if the device is an USB one or not. Here is an example : expandcollapse popupLocal $aUSBDrives = _ListUSBVolumes() Local $iRunFromUSB = 0 For $i = 1 To $aUSBDrives[0] If StringRegExp( @ScriptDir, "(?i)^" & $aUSBDrives[$i]) Then $iRunFromUSB = 1 ExitLoop EndIf Next If $iRunFromUSB Then MsgBox(0, "", "OK") Else MsgBox(16, "", "The program must be launched from an USB drive !") EndIf ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ListUSBVolumes ; Description ...: List USB volumes ; Syntax ........: _ListUSBVolumes() ; Parameters ....: None ; Return values .: An array of strings (USB drive letter followed by colon) of drives found. ; The zeroth array element contains the number of drives. ; Author ........: jguinch ; =============================================================================================================================== Func _ListUSBVolumes() Local $aResult[1] Local $oDrive, $sDeviceID, $oPartitions, $oPartition, $oLogicalDisks, $oLogicalDisk, $sDriveLetter Local $oWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2") Local $oDiskDrives = $oWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive Where InterfaceType = 'USB'") For $oDrive In $oDiskDrives $sDeviceID = StringReplace($oDrive.DeviceID, "\", "\\") $oPartitions = $oWMIService.ExecQuery _ ("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & _ $sDeviceID & """} WHERE AssocClass = " & _ "Win32_DiskDriveToDiskPartition") For $oPartition In $oPartitions $oLogicalDisks = $oWMIService.ExecQuery _ ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & _ $oPartition.DeviceID & """} WHERE AssocClass = " & _ "Win32_LogicalDiskToPartition") For $oLogicalDisk In $oLogicalDisks $sDriveLetter = $oLogicalDisk.DeviceID If $sDriveLetter <> "" Then Redim $aResult[ UBound($aResult) + 1] $aResult[ UBound($aResult) - 1] = $sDriveLetter EndIf Next Next Next $aResult[0] = UBound($aResult) - 1 Return $aResult EndFunc Shocker 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Shocker Posted October 6, 2014 Author Share Posted October 6, 2014 @jguinch Thx for reply! It works very GOOD - MERCI INFINIMENT Is it same Code for both OS (X86/64)? Link to comment Share on other sites More sharing options...
jguinch Posted October 6, 2014 Share Posted October 6, 2014 Yes Shocker 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now