Jump to content

Coying only USB Drives and Hard Drives


Recommended Posts

I got hold of AutoIT v3 very recently and im using it very much.

I stuck in a script where i want to copy a picture to all the hard drives and to the USB devices when they are connected.

For this purpose i used the "DrivegetDrive". But becuse there is no floppy disk inserted into the floppy drive the script gives an error informing that to insert a drive tothe floppy disk drive continuesly. giving options of "retry", "cancel". So please helpin this so that i can select only removable drives and hard drives to copy the picture.(Excluding CDROMS and Floppy disks).

If you hav a solution reply here or email meat mario_thilanga"yahoo.com

Link to comment
Share on other sites

Link to comment
Share on other sites

Hey KaFu;

Yhanx man for that reply. I tryed it out and it works fine.

I hav one more question is there a way to include to that script if there is an error to perform the next instruction of the script.coz my script doesnt perorm the next instruction when it meets the error. but stays stuck on that specific erorr trying to oerform the same instruction again and again....

I'm hoping that you or anyone else will answr this.

Thank you very much ones agin for thta perfect answer. you rule man!!!!!

coz i was stuck on that script for months. now i can cmplrtr it for good. :D

Link to comment
Share on other sites

Something like this should do the trick.

$var = DriveGetDrive( "all" )
If NOT @error Then
  ;MsgBox(4096,"", "Found " & $var[0] & " drives")
    For $i = 1 to $var[0]
;MsgBox(4096,"Drive " & $i, $var[$i])
        if DriveGetType($var[$i] & '\') = 'Removable' OR DriveGetType($var[$i] & '\') = 'Fixed' OR  DriveGetType($var[$i] & '\') = 'Network' Then
            if DriveStatus($var[$i] & '\') = 'READY' Then
            ConsoleWrite($var[$i] & '\' & @crlf)
    ; FileCopy ( "source", "dest" [, flag] )
            endif               
        EndIf
    Next
EndIf

If that doesn't fit your purpose, you'll have to provide some sample code :D...

Edited by KaFu
Link to comment
Share on other sites

Hey Kafu the reply you kept again didnt work also. i modified my earlier script which was this:

Do

$drive = DriveGetDrive( "All" )

For $from = 1 to $drive[0]

If FileExists ($drive[$from]&"\"&"My Picture.bmp") Then

sleep (1000)

Else

FileCopy ("C:\Pictures\My Picture.bmp",$drive[$from]&"\")

EndIf

Next

Until WinActive ("Stop")

To this with your help:

$drive = DriveGetDrive( "All" )

If NOT @error Then

For $from = 1 to $drive[0]

If DriveGetType($drive[$from] & '\') = 'Removable' OR DriveGetType($drive[$from] & '\') = 'Fixed' OR DriveGetType($drive[$from] & '\') = 'Network' Then

If DriveStatus($drive[$from] & '\') = 'READY' Then

If FileExists ($drive[$from]&"\"&"My Picture.bmp") Then

sleep (1000)

Else

FileCopy ("C:\Pictures\My Picture.bmp",$drive[$from]&"\")

EndIf

EndIf

EndIf

Next

EndIf

Until WinActive ("Stop")

But still it does not work

please help i am in a desperate situation.!!!!

IT stillgives the same error as "AUTOIT3-PIcture.exe - No disk" givig options of REtry Cancelo and Continue

Edited by MarioFernando
Link to comment
Share on other sites

$drive = DriveGetDrive("All")
If Not @error Then
    For $from = 1 To $drive[0]
        If DriveGetType($drive[$from] & '\') = 'Removable' Or DriveGetType($drive[$from] & '\') = 'Fixed' Or DriveGetType($drive[$from] & '\') = 'Network' Then
            If DriveStatus($drive[$from] & '\') = 'READY' Then
                If Not FileExists($drive[$from] & "\" & "My Picture.bmp") Then
                    FileCopy("C:\Pictures\My Picture.bmp", $drive[$from] & "\")
                    ConsoleWrite($drive[$from] & "\" & "My Picture.bmp" & @crlf)
                EndIf
            EndIf
        EndIf
    Next
EndIf

works fine for me... otherwise you'll have to provide more code (WinActive ("Stop")?), maybe the bug's not in this part... you may pm me...

Link to comment
Share on other sites

i thnk i solved it but not in the correct way i jst changed the "$from=1 to $drive[0]" to "$from=2 to $drive[0]" then always the floppy drives are excluded.but the thing is it excludes the C: drive also in a computer where their is no floppy drive.but i added a seperate script to copy the picture to C:.Anyway thanx for your utmost support.

hey do you know the way to attach a file to the email which is sent bt "InetEamil" command.

And the "Until WinActive ("Stop") was that i have a folder named as "stop" so when i open it the script should exit: :D

thank you. please leave a reply:

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