Jump to content

change drive's directives for quickly extract or performance


luis713
 Share

Recommended Posts

Typically you can manipulate the window's radio button if you identify it using AutoIt Window tool and then use Control funcs to select the radio button you want.

You could also implement the registry hack as described here http://forum.sysinternals.com/removable-drives-write-catching-option-option_topic18601_post94754.html#94754 , but I'm not sure if it will be effective 'real-time" or if it becomes effective the next time the removable device is plugged in.

edit:

forgot the link...derp

Edited by spudw2k
Link to comment
Share on other sites

if i use autoit window, do i need open first my pc, then clic on drive properties, and open all the neccesaries Windows in my code or all the radios on Windows have a different identifier?

pd. i want to do this procces in hidden way

Link to comment
Share on other sites

Yes, you'd have to open the properties window, and switch to the tab.

There are various ways to do this and even make it hidden but it's all smoke and mirrors at that point.

...i want to do this procces in hidden way

I'd recommend the registry method then.
Link to comment
Share on other sites

is there another method? i think could be posible calling a dll, but i don't know which dll, modifying registry won't be my best choice because the registry deppends of the drive, i need to know drive's name and other things

Link to comment
Share on other sites

I'm not finding a dll method, but I'm no expert.

You could use the function below to retrieve the proper device id/reg path for a known drive letter.

$drive = StringLeft(FileSelectFolder("Pick a Drive",""),2)
$id = _GetPNPDeviceID($drive,1)
msgbox(0,"",$id)

Func _GetPNPDeviceID($drive,$fullid=0)
$objWMIService = ObjGet("winmgmts:{impersonationLevel=Impersonate}!.rootcimv2")
If Not IsObj($objWMIService) Then Return -1 ;Failed to Connect to WMI on Local Machine

$colDevice = $objWMIService.ExecQuery("SELECT * from Win32_LogicalDiskToPartition")
$var=""
For $objItem in $colDevice
If StringInStr($objItem.Dependent,$drive) Then
$var=StringTrimLeft($objItem.Antecedent,stringInstr($objItem.Antecedent,"="))
EndIf
Next
If Not $var Then Return -2 ;Failed to Find Drive Letter

$colDevice = $objWMIService.ExecQuery("SELECT * from Win32_DiskDriveToDiskPartition")
$diskpartition = $var
$var=""
For $objItem in $colDevice
If StringInStr($objItem.Dependent,$diskpartition) Then
$var=StringTrimLeft($objItem.Antecedent,stringInstr($objItem.Antecedent,"="))
EndIf
Next
If Not $var Then Return -3 ;Failed to Find Physical Drive #

$colDevice = $objWMIService.ExecQuery("SELECT * from Win32_DiskDrive")
$physicaldrive = StringReplace(StringReplace($var,"",""),'"',"")
$var=""
For $objItem in $colDevice
If $objItem.DeviceID = $physicaldrive Then
$var=$objItem.PNPDeviceID
EndIf
Next
If Not $var Then Return -4 ;Failed to Find PNPDeviceID

If Not $fullid Then $var = StringTrimLeft($var,StringInstr($var,"",0,-1)) ;Return Ugly Full PNPDeviceID
Return $var
EndFunc

There is still the issue of when making the setting take effect. You could either remove and re-insert the device or use more trickery of sorts to automate it.

Edited by spudw2k
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...