Sign in to follow this  
Followers 0
alterctrlego

Searching for a file on multiple drives?

7 posts in this topic

I am writing a small program for a U3 memory stick, and one of the things that I need the program to do is locate a partition on the memory stick and tell a script the drive letter. The code that I have used so far is

Func getdrive()
    For $number=97 to 122
        Local $drive_l = Chr($number)
        Local $idnum = IniRead($drive_l&":\serial.ini","IDENTITY","SOFT_SERIAL","")
        If $idnum = "" Then
        Next
            Else
                Return($drive_l)
            EndIf
EndFunc

To the naked eye, this code should work, yet AutoIt doesn't allow programs to have "for" and "if" statements nesting in the way that I have them here...

Any ideas?

Help would be much appreciated. :">

AlterCtrlEgo,

http://www.alphahacka.com/ - Admin

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Would replacing the "For" loop with a "While" loop work?

Edited by acidfear

Share this post


Link to post
Share on other sites

It might, but I am still unsure about how to cycle through the letters while being able to exit out of the loop once the drive has been found.

Thanks,

AlterCtrlEgo

Share this post


Link to post
Share on other sites

Uten,

Thanks for the reply but,

I thought about using DriveGetDrive, but it wouldn't work for the my program as there may be many of one type of drive plugged into the computer at one time. :D I know there are other ways of identifying a drive but I think that looking for a value in a file is the most useful way for me :P

AlterCtrlEgo,

Thankful newb :)

Share this post


Link to post
Share on other sites

Func getdrive()
    Local $idnum
    $drives = DriveGetDrive('all')
    For $x = 1 To $drives[0]
        $idnum = IniRead($drives[$x] & "\serial.ini","IDENTITY","SOFT_SERIAL","")
        If $idnum <> "" Then Return($drives[$x])
    Next
    Return('')
EndFunc

Enjoy... :">


AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

Danny35d,

The script worked! Thanks for helping a thankful newbie!

Everyone,

Thanks for all your help and input!

AlterCtrlEgo

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