Jump to content

Recommended Posts

Posted

Hi,

Does anyone here know if its possible to search for a certain file and then run it if it exists..

Trying to work this out because I have an automated installation in place, but wanted to allow the user to insert a removable device before proceeding, which contains a file called copychart.exe. This file will be copied to the c:\something dir if its found.

Anyone have any ideas. I would think that 1 thing thats important is that it doesn't search the C: drive as this is not necessary as the file will always be stored on D,E,F,G etc...

thanks

Posted (edited)

1) DriveGetDrive to get drives, use with "REMOVABLE"?

2 a) Fixed path? e.g. root of device?

-> FileExists

b.) Do a recursive search (look in forum for example)

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Posted

  jben said:

Hi,

Does anyone here know if its possible to search for a certain file and then run it if it exists..

Trying to work this out because I have an automated installation in place, but wanted to allow the user to insert a removable device before proceeding, which contains a file called copychart.exe. This file will be copied to the c:\something dir if its found.

Anyone have any ideas. I would think that 1 thing thats important is that it doesn't search the C: drive as this is not necessary as the file will always be stored on D,E,F,G etc...

thanks

Quick and dirty - Only checks the root of the drive. You can add folder recursion with some of the other content in the help file (_FileListToArray(), etc):

$sSearchFile = "file.txt"
$aRemovableDrives = DriveGetDrive("REMOVABLE")

If IsArray($aRemovableDrives) Then
    For $i = 1 To $aRemovableDrives[0]
        If FileExists($aRemovableDrives[$i] &"\file.txt") Then
            MsgBox(64,"Found it","Found the file '" &$sSearchFile &"' on drive " &$aRemovableDrives[$i])
            ExitLoop
        EndIf
    Next
EndIf

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Posted

hmm thats interesting.

I seem to have got an error box stating:

Exception processing message 0xc00000a3 parameters

and then a load of number/letters

weird huh?

Posted

ahh i see why. I presume this is also checking my CD drives..Seems to show the error message a couple of times.

Posted
  jben said:

ahh i see why. I presume this is also checking my CD drives..Seems to show the error message a couple of times.

Actually, there's a separate parameter to handle CD drives ("CDROM" instead of "REMOVABLE"), though I don't know offhand what would be triggering the error noted in your earlier post.

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...