Jump to content

Help: Script which can run an exe in Pendrive or CDROM


Recommended Posts

I need your help guys,

I am trying to write a script which first search for the myexe.exe in myfolder of pen drive and if found, run that file and if no pendrive is found it search for the same file in the same folder of CDROM.

Till now I have done this:

$var = DriveGetDrive( "CDROM" )
If not @error Then
For $i = 1 to $var[0]
Run($var[$i] & "myfolder\myexe.exe")
Next
EndIf

But this search only in CDROM.

Edited by niceguy75
Link to comment
Share on other sites

$var = DriveGetDrive( "REMOVABLE" )
If $var<>"" Then
For $i = 1 to $var[0]
Run($var[$i] & "myfolder\myexe.exe")
Next
Else
    $var2 = DriveGetDrive( "CDROM" )
    run ($var2[$i] & "myfolder\myexe.exe")
EndIf

try it ...see whether this works... :)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Link to comment
Share on other sites

Thanks mate, currently I am at work place and I don't have Autoit installed here, I will test it at home in the eve and let you know.

BTW, nice to know that you are also from India.

Edit: not working mate.

Error: Variable used without being declared.

Edited by niceguy75
Link to comment
Share on other sites

Thanks mate, currently I am at work place and I don't have Autoit installed here, I will test it at home in the eve and let you know.

BTW, nice to know that you are also from India.

Edit: not working mate.

Error: Variable used without being declared.

Then declare the variable. It's easy.

Link to comment
Share on other sites

Local $Location, $Var = DriveGetDrive("ALL")
If IsArray($Var) Then
    For $i = 1 To $Var[0]
        If DriveGetType($Var[$i]) <> "REMOVABLE" And DriveGetType($Var[$i]) <> "CDROM" Then ContinueLoop ;skip Drive if not Removeable or CDROM
        If FileExists($Var[$i] & "\myfolder\myexe.exe") Then
            $Location = $Var[$i] & "\myfolder\myexe.exe" ;Finds first location of EXE file
            ExitLoop
        EndIf
    Next
EndIf
If $Location Then MsgBox(0, "Location of File", $Location)

Link to comment
Share on other sites

Thanks mate, I will try and let you know if its working or not.

Edit: Its only displaying the location of the exe not playing, I want my script to run myexe.exe of myfolder, as well.

Edited by niceguy75
Link to comment
Share on other sites

Thanks mate, I will try and let you know if its working or not.

Edit: Its only displaying the location of the exe not playing, I want my script to run myexe.exe of myfolder, as well.

It's obvious that the script only shows the location because there are no instructions able to run the program.

If $Location Then MsgBox(0, "Location of File", $Location)

I am a newbie as far as autoit is concerned, and I don't know how to declare the variable.

My friendly advice is to start reading the help manual and try to understand the meaning of commands and functions you need. I can see a bit of laziness from you in doing this. Edited by Cybergraph
Link to comment
Share on other sites

niceguy75,

So far the forum members have been giving you fish. Now it's time to learn how to fish...

Do a Google search on "rtfm"...

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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