Jump to content

input and combo


pcjunki
 Share

Recommended Posts

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

  • Moderators

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

so lets say i type in a computer name called "vadar1"

and i want to intall the java

which is located on \\server1\share\javainstall.exe

i would want to run this code to create a scheduled task

schtasks /create /st 09:40 /sc once /tn java /tr "\\server1\share\java.exe" /s vadar1 /ru domain\admin /rp pwd123

then execute the task

but i don't know how in autoit to pass vadar1 into the remote task i want to create

also could type in vadar2 or luke3

so i need a variable somehome, but don't know how to do it

Link to comment
Share on other sites

  • Moderators

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

  • Moderators

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

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 $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button1

MsgBox(0, "Testing", GUICtrlRead($Input1) & " " & GUICtrlRead($combo))

EndSwitch

WEnd

Edited by pcjunki
Link to comment
Share on other sites

  • Moderators

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

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)

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)

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

  • Moderators

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

  • Moderators

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

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 Gude
How 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

  • Moderators

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.

"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

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 away

to fast to see anything, i can't see the error from it

Link to comment
Share on other sites

  • Moderators

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

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 by pcjunki
Link to comment
Share on other sites

fixed it, i had a space

correct way is

Func link($pc)
FileCopy("[url="file://serversharelink"]serversharelink[/url] with spaces.url" , "" & $pc &"c$Documents and SettingsAll UsersDesktoplink with spaces.url" )
EndFunc
Edited by pcjunki
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...