pcjunki Posted August 1, 2012 Share Posted August 1, 2012 i'm trying to step up my game in the gui and scripting making, and i have this idea of pushing out software to computers on my network my idea is just to type in a "computer" name, and have a dropdown of some simple software to pushout. click and go here is what i have so far i'm not very good with variable and what not, so please be patient, i want to learn this. #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Remote Push", 307, 134, 213, 146) $Label1 = GUICtrlCreateLabel("Computer Name", 8, 8, 80, 17) $Input1 = GUICtrlCreateInput("", 8, 24, 137, 21) $combo = GUICtrlCreateCombo("Java Install", 152, 24, 137, 25) $combo = GUICtrlSetData(-1, "Adobe Flash|Adobe Reader") $Button1 = GUICtrlCreateButton("Install", 152, 48, 73, 57, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 1, 2012 Moderators Share Posted August 1, 2012 Hi, pcjunki. It looks like you are off to a good start. Do you have a specific question or problem you're running into? "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...
pcjunki Posted August 1, 2012 Author Share Posted August 1, 2012 so lets say i type in a computer name called "vadar1"and i want to intall the javawhich is located on \\server1\share\javainstall.exei would want to run this code to create a scheduled taskschtasks /create /st 09:40 /sc once /tn java /tr "\\server1\share\java.exe" /s vadar1 /ru domain\admin /rp pwd123then execute the taskbut i don't know how in autoit to pass vadar1 into the remote task i want to createalso could type in vadar2 or luke3so i need a variable somehome, but don't know how to do it Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 1, 2012 Moderators Share Posted August 1, 2012 Ah, ok. So you have your Input created, $Input1. What you want to look up in the help file is GuiCtrlRead. For example, try this expansion of your code. Type something in for the computer and then click the Install button. #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Remote Push", 307, 134, 213, 146) $Label1 = GUICtrlCreateLabel("Computer Name", 8, 8, 80, 17) $Input1 = GUICtrlCreateInput("", 8, 24, 137, 21) $combo = GUICtrlCreateCombo("Java Install", 152, 24, 137, 25) $combo = GUICtrlSetData(-1, "Adobe Flash|Adobe Reader") $Button1 = GUICtrlCreateButton("Install", 152, 48, 73, 57, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MsgBox(0, "Testing", GUICtrlRead($Input1)) EndSwitch WEnd "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...
pcjunki Posted August 1, 2012 Author Share Posted August 1, 2012 starting to understand and see where you are going at..woohoo but how does it know from the combos, like if i choose java, flash, or adobe reader Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 1, 2012 Moderators Share Posted August 1, 2012 Since $combo points to a control, you can use GUICtrlRead on it as well. I did just notice, however, that you are defining the $combo variable twice. Try giving this code a try: #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Remote Push", 307, 134, 213, 146) $Label1 = GUICtrlCreateLabel("Computer Name", 8, 8, 80, 17) $Input1 = GUICtrlCreateInput("", 8, 24, 137, 21) $combo = GUICtrlCreateCombo("Java Install", 152, 24, 137, 25) GUICtrlSetData(-1, "Adobe Flash|Adobe Reader") ;<------------------Here you were defining $combo for a second time, which is a no-no. Call it $combo1, or just leave it blank. $Button1 = GUICtrlCreateButton("Install", 152, 48, 73, 57, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MsgBox(0, "Testing", GUICtrlRead($Input1) & " " & GUICtrlRead($combo)); <---This will show you how it reads both controls. EndSwitch WEnd "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...
pcjunki Posted August 1, 2012 Author Share Posted August 1, 2012 (edited) very cool, i see how that works now!shouldn't i set a variable somehow for my installers?i decided to go with the pstools, much easier to execute and install software#include <GUIConstants.au3>#Region ### START Koda GUI section ### Form=$Form1 = GUICreate("Remote Push", 307, 134, 213, 146)$Label1 = GUICtrlCreateLabel("Computer Name", 8, 8, 80, 17)$Input1 = GUICtrlCreateInput("", 8, 24, 137, 21)$combo = GUICtrlCreateCombo("Java Install", 152, 24, 137, 25)GUICtrlSetData(-1, "Adobe Flash|Adobe Reader")$Button1 = GUICtrlCreateButton("Install", 152, 48, 73, 57, 0)GUISetState(@SW_SHOW)#EndRegion ### END Koda GUI section ###$java=("c:pstoolspsexec.exe" $input1 -u domainadmin -p pwd123 -c "serversharejre-7u5-windows-i586.exe" /s)$flash=("server1shareflashinstall.exe")$reader=("server1sharereader.exe")While 1$nMsg = GUIGetMsg()Switch $nMsgCase $GUI_EVENT_CLOSEExitCase $Button1MsgBox(0, "Testing", GUICtrlRead($Input1) & " " & GUICtrlRead($combo))EndSwitchWEnd Edited August 1, 2012 by pcjunki Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 1, 2012 Moderators Share Posted August 1, 2012 I typically like use functions with my case statements, for readability. So if I had an install for Java, one for Adobe Reader, and one for Flash, I would do it something like this. The Msgbox inside each function is just there to show you that you're pulling the correct data. You would put your install instructions as needed into each function. #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Remote Push", 307, 134, 213, 146) $Label1 = GUICtrlCreateLabel("Computer Name", 8, 8, 80, 17) $Input1 = GUICtrlCreateInput("", 8, 24, 137, 21) $combo = GUICtrlCreateCombo("Java_Install", 152, 24, 137, 25) GUICtrlSetData(-1, "Adobe_Flash|Adobe_Reader") $Button1 = GUICtrlCreateButton("Install", 152, 48, 73, 57, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $app = GUICtrlRead($combo) $pc = GUICtrlRead($Input1) Call($app, $pc) EndSwitch WEnd Func Adobe_Flash($pc) MsgBox(0, "", "Adobe Flash on PC " & $pc) EndFunc Func Adobe_Reader($pc) MsgBox(0, "", "Adobe Reader on PC " & $pc) EndFunc Func Java_Install($pc) MsgBox(0, "", "Java Install on PC " & $pc) EndFunc "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...
pcjunki Posted August 2, 2012 Author Share Posted August 2, 2012 now i'm getting a Error parsing function call(so close...this is awesome)here's what i have so far#include <GUIConstants.au3>#Region ### START Koda GUI section ### Form=$Form1 = GUICreate("Remote Push", 307, 134, 213, 146)$Label1 = GUICtrlCreateLabel("Computer Name", 8, 8, 80, 17)$Input1 = GUICtrlCreateInput("", 8, 24, 137, 21)$combo = GUICtrlCreateCombo("Java_Install", 152, 24, 137, 25)GUICtrlSetData(-1, "Adobe_Flash|Adobe_Reader")$Button1 = GUICtrlCreateButton("Install", 152, 48, 73, 57, 0)GUISetState(@SW_SHOW)#EndRegion ### END Koda GUI section ###While 1$nMsg = GUIGetMsg()Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $app = GUICtrlRead($combo) $pc = GUICtrlRead($Input1) Call($app, $pc)EndSwitchWEndFunc Adobe_Flash($pc);MsgBox(0, "", "Adobe Flash on PC " & $pc)EndFuncFunc Adobe_Reader($pc)MsgBox(0, "", "Adobe Reader on PC " & $pc)EndFuncFunc Java_Install($pc)ShellExecute ("c:\pstools\psexec.exe" [,"\\$pc -u domain\user -p pwd123 -c \\server\share\jre-7u5-windows-i586.exe /s" [, "" [, "" [, ]]]] )EndFunc Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 2, 2012 Moderators Share Posted August 2, 2012 Hi, pcjunki. Look in your shellexecute line. You have some stray [ symbols. Also, after the first comma in that line, you're going to want to do something like this: instead of: ShellExecute ("c:pstoolspsexec.exe" [,"$pc -u domainuser -p pwd123 -c serversharejre-7u5-windows-i586.exe /s" [, "" [, "" [, ]]]] ) try this, and compare to see the differences: ShellExecute ("c:pstoolspsexec.exe" ,"" & $pc & "-u domainuser -p pwd123 -c serversharejre-7u5-windows-i586.exe /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...
pcjunki Posted August 2, 2012 Author Share Posted August 2, 2012 i pulled a homer, and think i got it before you posted..."doh" put now as you can see in the attached image, i get a different error Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 2, 2012 Moderators Share Posted August 2, 2012 The thumbnail shows psexec trying to connect to the machine. Is it failing to do so? If so, is the machine pingable? Can you browse to the machine by typing in <machine>C$ in the run line? "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...
pcjunki Posted August 2, 2012 Author Share Posted August 2, 2012 yes the machine is on, if i run the command "manually" from a cmd, it works fine you can see where it's tring to connect to $pc i don't think the variable (if thats right) is passing through correctly Link to comment Share on other sites More sharing options...
BrewManNH Posted August 2, 2012 Share Posted August 2, 2012 pcjunki your quotes are in the wrong place. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 2, 2012 Moderators Share Posted August 2, 2012 pcjunki your quotes are in the wrong place.D'oh! LOL I missed that completely. As BrewManNH pointed out, your screenshot shows you trying to connect to $pc. That means your variable is not outside the "" as it should be. Make sure you have it written as I do in post #10. If you need, repost your full code. BrewManNH 1 "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...
pcjunki Posted August 2, 2012 Author Share Posted August 2, 2012 you guys rock btw...i fixed the quote thing..ShellExecute ("c:\pstools\psexec.exe" , "\\" & $pc & "-u domain\user -p pwd1234 -c \\server\share\jre-7u5-windows-i586.exe /s" , "" , "" )now a "dos" box, (the pstools) comes up, flashes and goes awayto fast to see anything, i can't see the error from it Link to comment Share on other sites More sharing options...
pcjunki Posted August 2, 2012 Author Share Posted August 2, 2012 I GOT IT! ShellExecute ("c:\pstools\psexec.exe" , "\\" & $pc &" -u i was able to see that the -u was being passed off into the pcname variable got it working! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 2, 2012 Moderators Share Posted August 2, 2012 Try setting the last flag in your ShellExecute to @SW_SHOW, like this: ShellExecute ("c:pstoolspsexec.exe" ,"" & $pc & " -u domainuser -p pwd123 -c serversharejre-7u5-windows-i586.exe /s", "", "", @SW_SHOW) If that doesn't resolve it, we may need to run it a different way. Do you see anything in your Event Viewer regarding why PSExec is failing? "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...
pcjunki Posted August 2, 2012 Author Share Posted August 2, 2012 (edited) i added another function to copy a file to the all users desktop (xp is the os) but it's not copying.... Func link($pc) FileCopy("serversharelink with spaces.url" , "" & $pc &" c$Documents and SettingsAll UsersDesktoplink with spaces.url" ) EndFunc Edited August 2, 2012 by pcjunki Link to comment Share on other sites More sharing options...
pcjunki Posted August 2, 2012 Author Share Posted August 2, 2012 (edited) fixed it, i had a spacecorrect way isFunc link($pc) FileCopy("[url="file://serversharelink"]serversharelink[/url] with spaces.url" , "" & $pc &"c$Documents and SettingsAll UsersDesktoplink with spaces.url" ) EndFunc Edited August 2, 2012 by pcjunki 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