y0_Aero Posted December 8, 2015 Share Posted December 8, 2015 I'm wanting to convert over two simple batch files over to AutoIT and completely automate them as currently i have to edit the batch files to change the workstation names.First batch file simply starts a service for a number of workstations, the line is as follows:sc \\WORKSTATIONNAME config SERVICENAME start= auto && sc \\WORKSTATIONNAME start SERVICENAMEAnd the second batch file runs an external program which runs through batch which remotely deletes user profiles, it's the same line repeated again as like the first line:\\NETWORKPATHOFPROGRAM /c:WORKSTATIONNAME /u /ed:admin*I'd like to be able to get the person to input the workstation names in a GUI input box and whatever they input to be put into the 'WORKSTATIONNAME' section of the line, i know this would be done using Variables but i can't get my head round how i'd be able to parse whatever they input and loop the line each time.If anyone could point out where to start or some functions that would be handy for me that would be great, thankyou. Link to comment Share on other sites More sharing options...
Exit Posted December 8, 2015 Share Posted December 8, 2015 (edited) What have you tried so far?Show us the code to help you. Edited December 8, 2015 by Exit App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
y0_Aero Posted December 8, 2015 Author Share Posted December 8, 2015 So far I've found that I can run the macro @ComSpec so I know I'd have to do something along the lines of:Run(@ComSpec & " /c WORKSTATIONNAME " & 'command', "", @SW_HIDE)So would I then set variables and place them in the 'WORKSTATIONNAME' line once inputted from a GUI? Link to comment Share on other sites More sharing options...
TheSaint Posted December 8, 2015 Share Posted December 8, 2015 Hi again y0_Aero.I suggest you whip up some code, including your GUI arrangement, and share that here (masking anything private).It is always much easier to get help if the asker provides some code first, which we can then modify where necessary.It also helps us understand what skill level you are at, so as to best target our help or advice.Like i said earlier in the Chatbox, you can do the full AutoIt thing and avoid Batch files, or you can implement both together, where your GUI setup has code to modify/edit the Batch files to meet your need. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
y0_Aero Posted December 8, 2015 Author Share Posted December 8, 2015 Hello TheSaint,So far i've mocked up the GUI arrangement and added some Menu's for future projects but the tab i'm focusing on at the moment is the 'Project' tab.#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Toolbox", 423, 309, 260, 140) $PageControl1 = GUICtrlCreateTab(0, 8, 444, 320) $TabSheet1 = GUICtrlCreateTabItem("Home") $Pic2 = GUICtrlCreatePic("\\pathofimage", 4, 33, 417, 273) $TabSheet2 = GUICtrlCreateTabItem("Project") $Edit1 = GUICtrlCreateEdit("", 16, 72, 169, 129) GUICtrlSetData(-1, "Edit1") GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Button1 = GUICtrlCreateButton("Submit", 16, 208, 89, 25) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Button2 = GUICtrlCreateButton("Clear", 112, 208, 73, 25) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $TabSheet3 = GUICtrlCreateTabItem("IP Tools") $TabSheet4 = GUICtrlCreateTabItem("Registry") $TabSheet5 = GUICtrlCreateTabItem("Programs") GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func workstation() Run(@ComSpec & " /c " & 'command & variable?', "", @SW_SHOW) End FuncNow i'm just unsure on how i get whatever is inputted into the edit box to be put into a ComSpec macro line, would it be set from a variable? Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted December 8, 2015 Share Posted December 8, 2015 (edited) When I was first starting I would use inputbox() rather than a full gui, and then when I had working code impliment the gui later. Of course Koda and the other tools makes it easy enough to create a quick and dirty gui but just an idea to pass along.As far as what you have the basic concept of passing a variable from a gui would be like this in most situations. (I commented where I added) expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Toolbox", 423, 309, 260, 140) $PageControl1 = GUICtrlCreateTab(0, 8, 444, 320) $TabSheet1 = GUICtrlCreateTabItem("Home") $Pic2 = GUICtrlCreatePic("\\pathofimage", 4, 33, 417, 273) $TabSheet2 = GUICtrlCreateTabItem("Project") $Edit1 = GUICtrlCreateEdit("", 16, 72, 169, 129) GUICtrlSetData(-1, "Edit1") GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Button1 = GUICtrlCreateButton("Submit", 16, 208, 89, 25) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Button2 = GUICtrlCreateButton("Clear", 112, 208, 73, 25) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $TabSheet3 = GUICtrlCreateTabItem("IP Tools") $TabSheet4 = GUICtrlCreateTabItem("Registry") $TabSheet5 = GUICtrlCreateTabItem("Programs") GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ;If Submit is Pressed... ExitLoop ;Exit the While Loop EndSwitch WEnd $EditValue = GUICtrlRead($Edit1) ;Get Value from $Edit1 workstation() ;Call our Function Func workstation() Run(@ComSpec & " /c " & $EditValue, "", @SW_SHOW) ;Plug in command & varible as needed beware quotes! EndFunc Edited December 8, 2015 by ViciousXUSMC Link to comment Share on other sites More sharing options...
Valuater Posted December 8, 2015 Share Posted December 8, 2015 Maybe... While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 workstation(GUICtrlRead($Edit1)) EndSwitch WEnd Func workstation($INFO) MsgBox(0,"Test", @ComSpec & " /c " & $INFO) ;~ Run(@ComSpec & " /c " & 'command & variable?', "", @SW_SHOW) EndFunc8) Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted December 8, 2015 Share Posted December 8, 2015 And as you can see from Valuater, if you do not want to exit the GUI then call the function, normally I exit my loop with a GUI and intend to close it after a button press. Link to comment Share on other sites More sharing options...
y0_Aero Posted December 8, 2015 Author Share Posted December 8, 2015 I understand what you mean about just using inputbox() rather than a koda gui to start i'll keep that in mind for the future!That's great so i can use GUICtrlRead to get the value from a variable then obviously call the function and use the ComSpec macro.So that works for the premise of what i want, now how would i handle it if multiple workstation names are entered in the edit box seperated by commas, how would i parse each workstation name and then get it to loop the two ComSpec macros that i want to run on each workstation.Thankyou both of you for your help! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 8, 2015 Moderators Share Posted December 8, 2015 If you are expecting a list, like so: AFWorkstation1, AFWorkstation2, AFWorkstation3, AFWorkstation4, take a look at StringSplit in the help file. You can use this in conjunction with GUICtrlRead. Then you call your function/loop and pass the name of the workstation(s). "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! 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