Jump to content

Noob trying to run a program with a changing drive letter


 Share

Recommended Posts

GuiCtrlCreatecombo("Drives", 250, 80, 120, 100)

GUICtrlSetData(-1, "A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z")

$varA = ControlGetText("Drives", "", "")

$wssetup = GuiCtrlCreateButton("wssetup", 320, 145)

GUICtrlSetOnEvent($wssetup, "wssetup")

Func wssetup()

Run("$varA:\wfx32\wssetup.exe")

EndFunc

here is my script. I cant seem to figure out how to get the drive letter in the combo box to be a variable to change into the func box. any ideas?

Link to comment
Share on other sites

Use string concatenation.

Run($varA & ":\wfx32\wssetup.exe")

GuiCtrlCreatecombo("Drives", 250, 80, 120, 100)

GUICtrlSetData(-1, "A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z")

$varA = ControlGetText("Drives", "", "")

$wssetup = GuiCtrlCreateButton("wssetup", 320, 145)

GUICtrlSetOnEvent($wssetup, "wssetup")

Func wssetup()

Run($varA & ":\wfx32\wssetup.exe")

EndFunc

ok here is what it says now. I still can't figure this out. I think I am overlooking something.

Link to comment
Share on other sites

GuiCtrlCreatecombo("Drives", 250, 80, 120, 100)

GUICtrlSetData(-1, "A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z")

$varA = ControlGetText("Drives", "", "")

$wssetup = GuiCtrlCreateButton("wssetup", 320, 145)

GUICtrlSetOnEvent($wssetup, "wssetup")

Func wssetup()

Run($varA & ":\wfx32\wssetup.exe")

EndFunc

ok here is what it says now. I still can't figure this out. I think I am overlooking something. I am just wanting to be able to change drive letter for that program.

Link to comment
Share on other sites

Are you trying to make a program that runs and does something on that drive? because if so, one way to identify that drive is to create a file on the root of the drive, like "This_drive.txt", doesn't have to be anything special, and then have autoit search for that file in all the drives that are connected, so then when it finds it, it knows it has the right drive. I'm not sure if this is what you want though, but it's a suggestion

We ought not to misbehave, but we should look as though we could.

Link to comment
Share on other sites

Are you trying to make a program that runs and does something on that drive? because if so, one way to identify that drive is to create a file on the root of the drive, like "This_drive.txt", doesn't have to be anything special, and then have autoit search for that file in all the drives that are connected, so then when it finds it, it knows it has the right drive. I'm not sure if this is what you want though, but it's a suggestion

Actually to better explain. i am trying to create this script to be able to change drive letters on the fly to point to different installs of this software and run that wssetup.exe. the path for run is fine. i am just trying to figure out how to be able to select a drive letter in the create combo box and have that variable be able to change in my func section.
Link to comment
Share on other sites

Thank you everyone for your help. I know i have another post with the same issue. I am trying to spread my question more so maybe i can get the issue resolved. I put your text it and it still doesnt work. I have created a button directly for it and that one seems to work. here is the whole script. hope it helps

<Code removed>

Edited by Valik
Link to comment
Share on other sites

Well, one error is this:

[color=#1C2837][font=arial, verdana, tahoma, sans-serif][size=2]Run("$var & :\wfx32\WWSETUP.EXE")[/size][/font][/color]

should be something like this:

[color=#1C2837][font=arial, verdana, tahoma, sans-serif][size=2]Run("$varA" & ":\wfx32\WWSETUP.EXE")[color=#000000][size=3]

that's how it was originally but i was playing aaround in it trying to get it to work. I put it back how you said and it still wont open the file. is there any other ways to have the drive letter change from what is selected in the combo list?

Func wssetup()

Run($varA & ":\wfx32\WWSETUP.EXE")

EndFunc

this is how it looks now.

Edited by netrecov
Link to comment
Share on other sites

All right, so here's your reading error: you put GUICtrlRead() RIGHT after you created the GUIComboBox, which will read the default value. In the loop you need to have it read the combobox when you click the setup, or some other button. It has to read it right before you execute whatever it is you want to do, otherwise it'll give an inaccurate value.

Test this out

Func wssetup()
    $varA = GUICtrlRead($MyCombo)
    MsgBox(0,"",$varA)
;~ Run("$var & :\wfx32\WWSETUP.EXE")
EndFunc

Run($varA & ":\wfx32\WWSETUP.EXE")
- no quotes around a variable name!

Ahh, yeah, sorry thanks. I wasn't paying attention Edited by mistersquirrle

We ought not to misbehave, but we should look as though we could.

Link to comment
Share on other sites

All right, so here's your reading error: you put GUICtrlRead() RIGHT after you created the GUIComboBox, which will read the default value. In the loop you need to have it read the combobox when you click the setup, or some other button. It has to read it right before you execute whatever it is you want to do, otherwise it'll give an inaccurate value.

Test this out

Func wssetup()
    $varA = GUICtrlRead($MyCombo)
    MsgBox(0,"",$varA)
;~ Run("$var & :\wfx32\WWSETUP.EXE")
EndFunc

ok i replace my old func with that one. ran it i got the message box "C". then took out the ";" for the run, re ran the script and nothing.

Link to comment
Share on other sites

Well, did you have it like

Func wssetup()
    $varA = GUICtrlRead($MyCombo)
    MsgBox(0,"",$varA)
 Run("$var & :\wfx32\WWSETUP.EXE")
EndFunc

??

or

Func wssetup()
    $varA = GUICtrlRead($MyCombo)
   ; MsgBox(0,"",$varA)
Run($varA & ":\wfx32\WWSETUP.EXE")
EndFunc

^that should return "c:\wfx32\WWSETUP.EXE" in the run command. "Run("$var & :\wfx32\WWSETUP.EXE")" would return "$var & :\wfx32\WWSETUP.EXE"

BTW, check your variables, you put just $var in the run command, which would yield nothing, I just caught that.

Edited by mistersquirrle

We ought not to misbehave, but we should look as though we could.

Link to comment
Share on other sites

ame='netrecov' date='07 December 2009 - 05:36 PM' timestamp='1260236212' post='751849']

Well, did you have it like

Func wssetup()
    $varA = GUICtrlRead($MyCombo)
    MsgBox(0,"",$varA)
 Run("$var & :\wfx32\WWSETUP.EXE")
EndFunc

??

or

Func wssetup()
    $varA = GUICtrlRead($MyCombo)
   ; MsgBox(0,"",$varA)
Run($varA & ":\wfx32\WWSETUP.EXE")
EndFunc

^that should return "c:\wfx32\WWSETUP.EXE" in the run command. "Run("$var & :\wfx32\WWSETUP.EXE")" would return "$var & :\wfx32\WWSETUP.EXE"

BTW, check your variables, you put just $var in the run command, which would yield nothing, I just caught that.

yeah i caught that too.... this is what i got now

$MyCombo = GuiCtrlCreatecombo("Drives", 250, 80, 120, 100)

GUICtrlSetData(-1, "A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z")

$wssetup = GuiCtrlCreateButton("wssetup", 320, 145)

GUICtrlSetOnEvent($wssetup, "wssetup")

then

Func wssetup()

$varA = GUICtrlRead($MyCombo)

; MsgBox(0,"",$varA)

Run($varA & ":\wfx32\WWSETUP.EXE")

EndFunc

;Func wssetup()

; Run($varA & ":\wfx32\WWSETUP.EXE")

;EndFunc

Func wssetup2()

Run("C:\wfx32\WSSETUP.EXE")

EndFunc

Link to comment
Share on other sites

that looks good to me, have you tested it? And is wssetup2 just for testing? since the drive is fixed, just to make sure it does actually work, right?

yes and yes, thats how i know it still isn't working. i have confirmed that the wssetup2 will successfully launch the software

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