Sign in to follow this  
Followers 0
niceguy75

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

9 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Then declare the variable. It's easy.

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

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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

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