Jump to content

Stupid Run Question sorry !


jslegers
 Share

Recommended Posts

Hi,

I have a strange problem. I have made a script which runs an exe that needs a parameter. Here is the script :

#include <GUIConstants.au3>

;Defining variables
$driveltr = ""
$prg = "RemoveDrive.exe"

;Creating GUI
GUICreate ( "Select Device", 175, 100, -1, -1, $WS_BORDER )
GUISetState ( @SW_SHOW )

;Creating radio buttons
$radio1 = GUICtrlCreateRadio ( "Portable Harddisk",5 ,5 ,150 )
$radio2 = GUICtrlCreateRadio ( "USB Flash Drive",5 ,25 ,150 )

;Creating action button
$button1 = GUICtrlCreateButton ( "Remove device" ,5 ,47 ,95 )
$button2 = GUICtrlCreateButton ( "Exit" ,135 ,47, 35 )

;Standard radio1 selected.
GUICtrlSetState ( $radio1, $GUI_CHECKED )

;Displaying GUI until it is closed.
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE or $msg = $button2
            ExitLoop
            
        Case $msg = $button1 
            If GUICtrlRead ( $radio1 ) = 1 Then $driveltr="P:"
            If GUICtrlRead ( $radio2 ) = 1 Then $driveltr="U:"
            RunWait ( $prg & $driveltr, @ScriptDir )
            Exit
    EndSelect
Wend
Exit

The $prg is the program and the $driveltr is the drive letter. It has to run like RemoveDrive.exe P: or RemoveDrive.exe U: it depends on the radio button. I't seems having a problem with & $driveltr. What am I doing wrong ?

Link to comment
Share on other sites

My guess that is that there would be no space as the command is passed so you would be receiving RemoveDrive.exeU:, you could try using shellexecute, that passes parameters

ShellExecute ( "filename" [, "parameters" [, "workingdir" [, "verb" [, showflag]]]] )

ShellExecute("RemoveDrive.exe",$driveltr,@scriptdir)

Kerros

Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

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