Shaun Burdick Posted July 18, 2006 Share Posted July 18, 2006 I am having a bit of a problem with this little funtion I wrote. For some reason, it will release the IP address, but it will error out when it goes to renew it. the error is: (Private information has been x'd out) xxxxxxxxxxxxxx.au3 (xxx) : ==> Unable to execute the external program.: RunWait(@ComSpec & " /c " & $sCommand & " /renew", "", @SW_HIDE) The directory name is invalid. Its odd, if I comment out the first RunWait, it will work fine. For some reason, it just does not want to run another command after the first one is completed. The code: expandcollapse popup;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ;~ Name: RefreshIP ;~ Usage: RefreshIP() ;~ Returns: null ;~ Local Variables: ;~ $pGui: a pointer to the GUI window created in this function ;~ $pText: a pointer to the GUICtrl label ;~ $sCommand: a string containing the correct windows command needed to ;~ refresh the IP(s) ;~ $sOS: a string that contains the detected OS group ;~ User Functions Used: none ;~ Description: ;~ RefreshIP will release and renew the computers IP(s) ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Func RefreshIP() Local $pGui Local $pText Local $sCommand = "winipcfg";ah good ol' 9x Local $sOS = "9X/ME" $pGui = GUICreate("Refreshing IP Address(es)...", 220, 90, -1, -1, _ BitOR($WS_POPUP, $WS_CAPTION), $WS_EX_TOPMOST) $pText = GUICtrlCreateLabel("- Checking OS Version..." & _ @LF & @LF & "- Releasing IP(s)..." & _ @LF & @LF & "- Renewing IP(s)...", 10, 10, 200, 80) GUISetState() ;Check for Windows Version Switch @OSVersion Case "Win_XP" $sCommand = "ipconfig" $sOS = "NT/2000/XP" Case "Win_2000" $sCommand = "ipconfig" $sOS = "NT/2000/XP" Case "Win_NT4" $sCommand = "ipconfig" $sOS = "NT/2000/XP" Case "Win_2003" $sCommand = "ipconfig" $sOS = "NT/2000/XP" ;God help anyone who has ME or 9X EndSwitch GUICtrlSetData($pText, "- Checking OS Version... " & $sOS & _ @LF & @LF & "- Releasing IP(s)..." & _ @LF & @LF & "- Renewing IP(s)...") RunWait(@ComSpec & " /c " & $sCommand & " /release", "", @SW_HIDE) GUICtrlSetData($pText, "- Checking OS Version... " & $sOS & _ @LF & @LF & "- Releasing IP(s)... Done." & _ @LF & @LF & "- Renewing IP(s)...") RunWait(@ComSpec & " /c " & $sCommand & " /renew", "", @SW_HIDE) GUICtrlSetData($pText, "- Checking OS Version... " & $sOS & _ @LF & @LF & "- Releasing IP(s)... Done." & _ @LF & @LF & "- Renewing IP(s)... Done.") Sleep(3000) GUICtrlDelete($pText) GUIDelete($pGui) EndFunc;End RefreshIP() --ShaunProject PageProjects:[Drive and Printer List Tool] [RunAS Box Tool] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 18, 2006 Moderators Share Posted July 18, 2006 (edited) What happens when you make " /release" and " /renew" to "/release" and "/renew"? (taking the leading space out) Edit: Forgot a space in one of my examples lol. Edited July 18, 2006 by SmOke_N 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 More sharing options...
Shaun Burdick Posted July 18, 2006 Author Share Posted July 18, 2006 (edited) The prefix space is needed as part of the command. (i.e. you can't do ipconfig/release you need ipconfig /release) Edited July 18, 2006 by Shaun Burdick --ShaunProject PageProjects:[Drive and Printer List Tool] [RunAS Box Tool] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 18, 2006 Moderators Share Posted July 18, 2006 Worked for me without the space... bring up cmd.exe from run and type in ipconfig/release ... ipconfig/renew it will work just fine. 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 More sharing options...
Shaun Burdick Posted July 18, 2006 Author Share Posted July 18, 2006 (edited) ok, but I am not sure that is the problem. It will not even make it to the commad prompt If you take out the @SW_HIDE you will see that the first command opens the window and runs, but the second command will not even open the command interpreter. its not failing on the "ipconfig" part, its failing on opening @ComSpec For the sake of it, I tried it and it still happened. Edited July 18, 2006 by Shaun Burdick --ShaunProject PageProjects:[Drive and Printer List Tool] [RunAS Box Tool] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 18, 2006 Moderators Share Posted July 18, 2006 Shaun... Either way is working for me (space or no space) with your example code... XP Pro SP2 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 More sharing options...
Shaun Burdick Posted July 18, 2006 Author Share Posted July 18, 2006 (edited) Wat version of AutoIT are you using, I was using 3.1.1.127 I thought that was the problem, so I moved up to 3.1.1.130 and it still gives me that error with out without the space. Edited July 18, 2006 by Shaun Burdick --ShaunProject PageProjects:[Drive and Printer List Tool] [RunAS Box Tool] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 18, 2006 Moderators Share Posted July 18, 2006 Wat version of AutoIT are you using, I was using 3.1.1.127I thought that was the problem, so I moved up to 3.1.1.130 and it still gives me that error with out without the space.3.1.1.130 is what I'm using. 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 More sharing options...
MHz Posted July 18, 2006 Share Posted July 18, 2006 Well, I see little wrong with it. Maybe a PATH issue on the testing system? Try doing manually via commandline and see if OK. Your Switch statement can be tweaked ;Check for Windows Version Switch @OSVersion Case "Win_NT4", "Win_2000", "Win_XP", "Win_2003" $sCommand = "ipconfig" $sOS = "NT/2000/XP" ;God help anyone who has ME or 9X EndSwitch I like the last comment. Link to comment Share on other sites More sharing options...
Shaun Burdick Posted July 18, 2006 Author Share Posted July 18, 2006 Well, I see little wrong with it. Maybe a PATH issue on the testing system? Try doing manually via commandline and see if OK. Your Switch statement can be tweaked ;Check for Windows Version Switch @OSVersion Case "Win_NT4", "Win_2000", "Win_XP", "Win_2003" $sCommand = "ipconfig" $sOS = "NT/2000/XP" ;God help anyone who has ME or 9X EndSwitch oÝ÷ ØbëazV¬µÊ&éíþ«¨µëajy,~íë0×!²Özg§´hm¶§+lj+,¹æ¬¶»-FéÖj+p¢¹,ë-~)ÞJ^¶Æëy©"µÚ0«¢+Ø)IÕ¹]¥Ð¡ ½µMÁµÀìÅÕ½Ðì½ÅÕ½ÐìµÀìÀÌØíÍ ½µµ¹µÀìÅÕ½Ðì½É±ÍÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°M]}!%¤(%U% ÑɱMÑÑ ÀÌØíÁQáа$ÅÕ½Ðì´ ¡¥¹=LYÉÍ¥½¸¸¸¸ÅÕ½ÐìµÀìÀÌØíÍ=LµÀì|($%1µÀì1µÀìÅÕ½Ðì´I±Í¥¹%@¡Ì¤¸¸¸½¹¸ÅÕ½ÐìµÀì|($%1µÀì1µÀìÅÕ½Ðì´I¹Ý¥¹%@¡Ì¤¸¸¸ÅÕ½Ðì¤((%IÕ¹]¥Ð¡ ½µMÁµÀìÅÕ½Ðì½ÅÕ½ÐìµÀìÀÌØíÍ ½µµ¹µÀìÅÕ½Ðì½É¹ÜÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°M]}!%¤íÑ¡¥ÌѡɽÝÌÑ¡ÉɽÈ(%U% ÑɱMÑÑ ÀÌØíÁQáа$ÅÕ½Ðì´ ¡¥¹=LYÉÍ¥½¸¸¸¸ÅÕ½ÐìµÀìÀÌØíÍ=LµÀì|($%1µÀì1µÀìÅÕ½Ðì´I±Í¥¹%@¡Ì¤¸¸¸½¹¸ÅÕ½ÐìµÀì|($%1µÀì1µÀìÅÕ½Ðì´I¹Ý¥¹%@¡Ì¤¸¸¸½¹¸ÅÕ½Ðì¤(oÝ÷ Ù«¢+Ø(íIÕ¹]¥Ð¡ ½µMÁµÀìÅÕ½Ðì½ÅÕ½ÐìµÀìÀÌØíÍ ½µµ¹µÀìÅÕ½Ðì½É±ÍÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°M]}!%¤(ì%U% ÑɱMÑÑ ÀÌØíÁQáа$ÅÕ½Ðì´ ¡¥¹=LYÉÍ¥½¸¸¸¸ÅÕ½ÐìµÀìÀÌØíÍ=LµÀì|($ì%1µÀì1µÀìÅÕ½Ðì´I±Í¥¹%@¡Ì¤¸¸¸½¹¸ÅÕ½ÐìµÀì|($ì%1µÀì1µÀìÅÕ½Ðì´I¹Ý¥¹%@¡Ì¤¸¸¸ÅÕ½Ðì¤((%IÕ¹]¥Ð¡ ½µMÁµÀìÅÕ½Ðì½ÅÕ½ÐìµÀìÀÌØíÍ ½µµ¹µÀìÅÕ½Ðì½É¹ÜÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°M]}!%¤í¥ÐÝ¥±°ÉÕ¸¹½Ü(%U% ÑɱMÑÑ ÀÌØíÁQáа$ÅÕ½Ðì´ ¡¥¹=LYÉÍ¥½¸¸¸¸ÅÕ½ÐìµÀìÀÌØíÍ=LµÀì|($%1µÀì1µÀìÅÕ½Ðì´I±Í¥¹%@¡Ì¤¸¸¸½¹¸ÅÕ½ÐìµÀì|($%1µÀì1µÀìÅÕ½Ðì´I¹Ý¥¹%@¡Ì¤¸¸¸½¹¸ÅÕ½Ðì¤(oÝ÷ Ù«¢+Ø)IÕ¹]¥Ð¡ ½µMÁµÀìÅÕ½Ðì½ÅÕ½ÐìµÀìÀÌØíÍ ½µµ¹µÀìÅÕ½Ðì½É±ÍÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°M]}!%¤)IÕ¹]¥Ð¡ ½µMÁµÀìÅÕ½Ðì½ÅÕ½ÐìµÀìÀÌØíÍ ½µµ¹µÀìÅÕ½Ðì½É¹ÜÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°M]}!%¤( There is no difference in these 2 statements aside frome the /release -> /renew --ShaunProject PageProjects:[Drive and Printer List Tool] [RunAS Box Tool] Link to comment Share on other sites More sharing options...
MHz Posted July 18, 2006 Share Posted July 18, 2006 (edited) I would try a small Sleep between the 2, incase the system is not ready for the renew. AutoIt is quick, but sometimes too quick. A Sleep(10) may do help perhaps. And aleast do please confirm the commandline via prompt unless tested already. Sometimes we all fall for a simple mistake. Edit: For trouble shooting, remove the @SW_HIDE and try /k instead of /c with @ComSpec. Edited July 18, 2006 by MHz Link to comment Share on other sites More sharing options...
Shaun Burdick Posted July 18, 2006 Author Share Posted July 18, 2006 (edited) I would try a small Sleep between the 2, incase the system is not ready for the renew. AutoIt is quick, but sometimes too quick. A Sleep(10) may do help perhaps.And aleast do please confirm the commandline via prompt unless tested already. Sometimes we all fall for a simple mistake.Edit:For trouble shooting, remove the @SW_HIDE and try /k instead of /c with @ComSpec.Nope that didn't work either, I put a Sleep(500) in there to no avail, I even put in a MsgBox(0,"",@ComSpec & " /c " & $sCommand & " /renew") which will pause it for a while and show "C:\windows\system32\cmd.exe /c ipconfig /renew", and it still didn't workI tried the /k and removed the @SH_HIDE, and the first command window opened just fine, I closed it, clicked ok on the msgbox, and it crashed with the same error, it doesn't even open the command window. Edited July 18, 2006 by Shaun Burdick --ShaunProject PageProjects:[Drive and Printer List Tool] [RunAS Box Tool] Link to comment Share on other sites More sharing options...
Shaun Burdick Posted July 18, 2006 Author Share Posted July 18, 2006 SUCCESS!!!The final code:expandcollapse popup;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ;~ Name: RefreshIP ;~ Usage: RefreshIP() ;~ Returns: null ;~ Local Variables: ;~ $pGui: a pointer to the GUI window created in this function ;~ $pText: a pointer to the GUICtrl label ;~ $sCommand: a string containing the correct windows command needed to ;~ refresh the IP(s) ;~ $sOS: a string that contains the detected OS group ;~ User Functions Used: none ;~ Description: ;~ RefreshIP will release and renew the computers IP(s) ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Func RefreshIP() Local $pGui Local $pText Local $sCommand = "winipcfg";ah good ol' 9x Local $sOS = "9X/ME" $pGui = GUICreate("Refreshing IP Address(es)...", 220, 90, -1, -1, _ BitOR($WS_POPUP, $WS_CAPTION), $WS_EX_TOPMOST) $pText = GUICtrlCreateLabel("- Checking OS Version..." & _ @LF & @LF & "- Releasing IP(s)..." & _ @LF & @LF & "- Renewing IP(s)...", 10, 10, 200, 80) GUISetState() ;Check for Windows Version Switch @OSVersion Case "Win_NT4", "Win_2000", "Win_XP", "Win_2003" $sCommand = "ipconfig" $sOS = "NT/2000/XP" ;God help anyone who has ME or 9X EndSwitch GUICtrlSetData($pText, "- Checking OS Version... " & $sOS & _ @LF & @LF & "- Releasing IP(s)..." & _ @LF & @LF & "- Renewing IP(s)...") RunWait(@ComSpec & " /c " & $sCommand & " /release", @SystemDir, @SW_HIDE) GUICtrlSetData($pText, "- Checking OS Version... " & $sOS & _ @LF & @LF & "- Releasing IP(s)... Done." & _ @LF & @LF & "- Renewing IP(s)...") RunWait(@ComSpec & " /c " & $sCommand & " /renew", @SystemDir, @SW_HIDE) GUICtrlSetData($pText, "- Checking OS Version... " & $sOS & _ @LF & @LF & "- Releasing IP(s)... Done." & _ @LF & @LF & "- Renewing IP(s)... Done.") Sleep(3000) GUICtrlDelete($pText) GUIDelete($pGui) EndFunc;End RefreshIP()Going from what this Support Document says, I figured I would give setting the path a shot. And it worked!!!For some odd reason it needed @SystemDir as a path for it to run the second command.Thank you all for your help, I really appreciate it. --ShaunProject PageProjects:[Drive and Printer List Tool] [RunAS Box Tool] Link to comment Share on other sites More sharing options...
MHz Posted July 18, 2006 Share Posted July 18, 2006 Congrats. Unless you are using RunAsSet() then do check your PATH variable as possible issue there for failure, or perhaps a Microsoft bug with IPConfig for some reason. Just type PATH at a command prompt and it should supply paths to your system directory. Glad problem is solved. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now