surfdork Posted December 13, 2009 Posted December 13, 2009 Good evening, I've just spent the entire day attempting to get a script that shows an IP, releases and renews then changes the proxy information in the registry. I already have the proxy updte script written in VBS so I'm concentrating on the IP identify and bounce. I tried to get multiple function to interface with .HTA and had no success so I figured I'd try with auto it. My intent is via a GUI to show a machines IP upon a button click and display the proxy info including exceptions. Upon the button click I want to do the following. Get IP and show in the window. release the current IP and verify this did occur successfully. Renew the IP and verify this was successful by comparing the release IP value with the ip issued at renewal. Update the registry with hard coded proxy values and display the proxy info in one window. THere will be 2 buttons one for proxy value a and one for proxy value b. Heresa what I wanted to dol the GUI question come later ;;get the local IP address Attempt at looping DIM $IP = @IPAddress1 Const $constIP = @IPaddress1 MsgBox (0,"",$IP,5) ;Release the IP reason for the loop is that the ipconfig comand tends to fail with @sw_hide I wish it didno because the cmd prompts change what I'm attempting to do RunWait (@ComSpec & " /c" & "IPCONFIG.EXE /release",@SW_HIDE) While 1 $IP = $constIP Run(@ComSpec & " /c" & "IPCONFIG.EXE /release") wend ;Until $IP <>$constIP ;Display the IP DIM $IP = @IPAddress1 Const $constIP2 = @IPaddress1 MsgBox (0,"",$IP,5) Run(@ComSpec & " /c" & "IPCONFIG.EXE /renew",@SW_HIDE) While 1 $IP = $constIP2 Run(@ComSpec & " /c" & "IPCONFIG.EXE /renew") Wend $IP = @IPAddress1 ;Display the IP the msg boxes are to show the ip in progress MsgBox (0,"",$IP,5) This is what I ended up settling on, it's ugly and does not lend itself to a gui ;get the local IP address $IP = @IPAddress1 Const $constIP = @IPaddress1 MsgBox (0,"",$IP,2) ;Release the IP RunWait (@ComSpec & " /c" & "IPCONFIG.EXE /release") $IP = @IPAddress1 MsgBox (0,"",$IP,2) RunWait(@ComSpec & " /c" & "IPCONFIG.EXE /renew") $IP = @IPAddress1 MsgBox (0,"",$IP,5) More questions: I want to create a simple GUI with 3 buttons containg 2 message boxes with IP and proxy output. Is there a tool simpler than KODA that a novice can connect simple scripts to? Thank you for your time.
surfdork Posted December 13, 2009 Author Posted December 13, 2009 Hi, this is simpler. I can build from here if I can figure out how to get RunWait(@ComSpec & " /c" & "IPCONFIG.EXE /renew") to work with @SW_HIDE) in order to suppress the dos window. I don't know how to make and output text field, what woud I change $input1=GuiCtrlCreateInput ( this is the only template I can think of). How do I launch this with a button? I really need assisstance. I've read the help files andhave been googling furiously. I'm just not getting it. GuiCreate("SkyRoom IP Reconfig",515,130,518,83) $button1=GuiCtrlCreateButton("10.10 reconfigure",46,105,465,24) $input1=GuiCtrlCreateInput("IP",44,14,403,20) GuiSetState() While 1 $msg=GuiGetMsg() If $msg=-3 Then Exit If $msg=$button1 Then button1() Wend ;get the local IP address $IP = @IPAddress1 ;Release the IP RunWait (@ComSpec & " /c" & "IPCONFIG.EXE /release") $IP = @IPAddress1 RunWait(@ComSpec & " /c" & "IPCONFIG.EXE /renew") $IP = @IPAddress1 ;now I show the value of @ipaddress1 in a text box Func button1() EndFunc
Monolith Posted December 13, 2009 Posted December 13, 2009 (edited) Hi surfdork You may want to correct some of your core code before you begin. it is best to check your syntax first before getting into creating gui's etc etc. orginal: RunWait(@ComSpec & " /c" & "IPCONFIG.EXE /renew") corrected: RunWait(@ComSpec & ' /c ' & 'IPCONFIG /renew', @sysdir, @sw_hide) ;please note that there is a [space] ' /c [space] ' & 'ipconfig /renew' Sorry don't have time to work the whole process for you have my own C# project currently. I would suggest reading help file {GUICtrlCreateButton, GUICtrlSetOnEvent, Func()} I would enclose allot of your code into functions which once a button is pressed will call for the func and execute the command which will make it allot cleaner to read. all the best Edited December 13, 2009 by Monolith
surfdork Posted December 13, 2009 Author Posted December 13, 2009 Thanks, this works like a charm however RunWait(@ComSpec & ' /c ' & 'IPCONFIG /renew', @sysdir, @sw_hide) ;please note that there is a [space] ' /c [space] ' & 'ipconfig /renew' should read @systemdir instead of @sysdir I appreciate the help and will freely share what I've learned in the future. All the best to your c# project.
Monolith Posted December 14, 2009 Posted December 14, 2009 Thanks, this works like a charm however RunWait(@ComSpec & ' /c ' & 'IPCONFIG /renew', @sysdir, @sw_hide) ;please note that there is a [space] ' /c [space] ' & 'ipconfig /renew' should read @systemdir instead of @sysdir I appreciate the help and will freely share what I've learned in the future. All the best to your c# project. Yes you are right with @systemdir, i wrote that free hand and quick.. lol, but typing @sys would of yielded the desired result with scite prompting. thanks still learning C# good luck with your endeavor Monolith
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