wi1d Posted October 26, 2005 Posted October 26, 2005 For the life of me I can't figure out what I'm doing wrong here. I'm wanting to be able to set up a console that launches commands. Everything seems to be working fine with one exception. I'm having trouble feeding the $host variable as a parameter into the commands. I've added msgbox's to echo $host and it turns out that the variable is being set correctly but when the command is executed it can't read $host.I know for fact my parameters for the vncviewer.exe are correct. Also, psshutdown logs off localhost when executed. Again this makes me think that $host isn't being read. Anyone suggestions would be greatly apprecaited since I'm about to pull out what hair I have left. Thanks. expandcollapse popup#include <GUIConstants.au3> AutoItSetOption ("TrayIconHide", 1); hide tray icon ; Variables Dim $installDir, $binDir, $vncPasswd Global $host $installDir = "C:\Program Files\AdminConsole" $binDir = $installDir & "\bin" $vncPasswd = "" ;; Arrays Dim $cmdCheckbox[39],$cmd[39] $cmdCheckbox[0] = 38 $cmd[0] = 38 ;; Commands $cmd[1] = $binDir & "\vncviewer.exe -connect " & $host & " -password " & $vncPasswd $cmd[2] = $binDir & "\vncviewer.exe -connect " & $host & " -password " & $vncPasswd & " -viewonly" $cmd[3] = $binDir & "\psshutdown.exe -o -f " & $host $cmd[4] = $binDir & "\vncviewer.exe -connect " & $host & " -password " & $vncPasswd & " -viewonly"; filler $cmd[5] = $binDir & "\vncviewer.exe -connect " & $host & " -password " & $vncPasswd & " -viewonly"; filler ; W , H , X, Y GUICreate("Administrative Console v0.1",550,242,-1,-1,BitOr($WS_MINIMIZEBOX,$WS_MAXIMIZEBOX,$WS_GROUP,$WS_CAPTION,$WS_POPUP,$WS_SYSMENU)) ; main tree structure & items $maintree = GUICtrlCreateTreeView (10,10,145,180) $aboutItem = GUICtrlCreateTreeViewItem ("About",$maintree) $lawyersItem = GUICtrlCreateTreeViewItem ("Lawyers",$maintree) $adminItem = GUICtrlCreateTreeViewItem ("Administration",$maintree) $piItem = GUICtrlCreateTreeViewItem ("Personal Injury",$maintree) $paralegalsItem = GUICtrlCreateTreeViewItem ("Paralegals",$maintree) $receptionistItem = GUICtrlCreateTreeViewItem ("Receptionist",$maintree) $helpItem = GUICtrlCreateTreeViewItem ("Help",$maintree) $l1 = GUICtrlCreateTreeViewItem ("L1",$lawyersItem) $l2 = GUICtrlCreateTreeViewItem ("L2",$lawyersItem) $l3 = GUICtrlCreateTreeViewItem ("L3",$lawyersItem) $l4 = GUICtrlCreateTreeViewItem ("L4",$lawyersItem) $a1 = GUICtrlCreateTreeViewItem ("A1",$adminItem) $a2 = GUICtrlCreateTreeViewItem ("A2",$adminItem) $a3 = GUICtrlCreateTreeViewItem ("A3",$adminItem) $descGroup = GUICtrlCreateGroup ("Description",180,145,180,55); X,Y,W,H GUICtrlSetState (-1,$GUI_HIDE) $commandsGroup = GUICtrlCreateGroup ("Commands",180,10,180,135) GUICtrlSetState (-1,$GUI_HIDE) ; Lawyer Tree structure (This is where the commands will go.) $commandsTree = GUICtrlCreateTreeView (190,30,160,100,BitOr($TVS_CHECKBOXES,$TVS_DISABLEDRAGDROP),$WS_EX_CLIENTEDGE); X,Y,W,H GUICtrlSetState (-1,$GUI_HIDE) $cmdCheckbox[1] = GUICtrlCreateTreeViewItem ("VNC - Interactive",$commandsTree) $cmdCheckbox[2] = GUICtrlCreateTreeViewItem ("VNC - View-only",$commandsTree) $cmdCheckbox[3] = GUICtrlCreateTreeViewItem ("Logoff",$commandsTree) $cmdCheckbox[4] = GUICtrlCreateTreeViewItem ("Reboot",$commandsTree) $cmdCheckbox[5] = GUICtrlCreateTreeViewItem ("Shutdown",$commandsTree) ; Labels and buttons $startlabel = GUICtrlCreateLabel ("Administrative Console v0.1" & @CRLF & @CRLF & _ "Written by Glen Smith" & @CRLF & @CRLF & "The purpose of this program is to create an" & _ " easy to use interface for the facilitation of technical administrative task around" & _ " the office.",275,52,175,110) $lawyersLabel = GUICtrlCreateLabel ("Lawyer's Group" & @CRLF & @CRLF & "This group contain several" & _ " task to control the computers for the Lawyer's Group.",175,10,200,110) GUICtrlSetState (-1,$GUI_HIDE) $adminLabel = GUICtrlCreateLabel ("Admin's Group" & @CRLF & @CRLF & "This group contain several" & _ " task to control the computers for the Admin's Group.",175,10,200,110) GUICtrlSetState (-1,$GUI_HIDE) $okbutton = GUICtrlCreateButton ("Execute",10,200,70,20) $cancelbutton = GUICtrlCreateButton ("Exit",90,200,70,20) ; Gui message loop GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $maintree GUIctrlSetState ($commandsTree,$GUI_HIDE) GUIctrlSetState ($commandsGroup,$GUI_HIDE) GUIctrlSetState ($descGroup,$GUI_HIDE) GUIctrlSetState ($lawyersLabel,$GUI_HIDE) GUIctrlSetState ($startLabel,$GUI_SHOW) GUIctrlSetState ($adminLabel,$GUI_HIDE) Case $msg = $aboutItem GUIctrlSetState ($commandsTree,$GUI_HIDE) GUIctrlSetState ($commandsGroup,$GUI_HIDE) GUIctrlSetState ($descGroup,$GUI_HIDE) GUIctrlSetState ($lawyersLabel,$GUI_HIDE) GUIctrlSetState ($startLabel,$GUI_SHOW) GUIctrlSetState ($adminLabel,$GUI_HIDE) Case $msg = $l1 GUIctrlSetState ($commandsTree,$GUI_SHOW) GUIctrlSetState ($commandsGroup,$GUI_SHOW) GUIctrlSetState ($descGroup,$GUI_SHOW) GUIctrlSetState ($lawyersLabel,$GUI_HIDE) GUIctrlSetState ($startLabel,$GUI_HIDE) GUIctrlSetState ($adminLabel,$GUI_HIDE) $host = "l1" Case $msg = $l2 GUIctrlSetState ($commandsTree,$GUI_SHOW) GUIctrlSetState ($commandsGroup,$GUI_SHOW) GUIctrlSetState ($descGroup,$GUI_SHOW) GUIctrlSetState ($lawyersLabel,$GUI_HIDE) GUIctrlSetState ($startLabel,$GUI_HIDE) GUIctrlSetState ($adminLabel,$GUI_HIDE) $host = "l2" Case $msg = $l3 GUIctrlSetState ($commandsTree,$GUI_SHOW) GUIctrlSetState ($commandsGroup,$GUI_SHOW) GUIctrlSetState ($descGroup,$GUI_SHOW) GUIctrlSetState ($lawyersLabel,$GUI_HIDE) GUIctrlSetState ($startLabel,$GUI_HIDE) GUIctrlSetState ($adminLabel,$GUI_HIDE) Case $msg = $l4 GUIctrlSetState ($commandsTree,$GUI_SHOW) GUIctrlSetState ($commandsGroup,$GUI_SHOW) GUIctrlSetState ($descGroup,$GUI_SHOW) GUIctrlSetState ($lawyersLabel,$GUI_HIDE) GUIctrlSetState ($startLabel,$GUI_HIDE) GUIctrlSetState ($adminLabel,$GUI_HIDE) Case $msg = $lawyersItem GUIctrlSetState ($commandsTree,$GUI_HIDE) GUIctrlSetState ($startLabel,$GUI_HIDE) GUIctrlSetState ($commandsGroup,$GUI_HIDE) GUIctrlSetState ($descGroup,$GUI_HIDE) GUIctrlSetState ($lawyersLabel,$GUI_SHOW) GUIctrlSetState ($adminLabel,$GUI_HIDE) Case $msg = $adminItem GUIctrlSetState ($commandsTree,$GUI_HIDE) GUIctrlSetState ($startLabel,$GUI_HIDE) GUIctrlSetState ($commandsGroup,$GUI_HIDE) GUIctrlSetState ($descGroup,$GUI_HIDE) GUIctrlSetState ($lawyersLabel,$GUI_HIDE) GUIctrlSetState ($adminLabel,$GUI_SHOW) Case $msg = $helpItem MsgBox(0, "How to use Administrative Console", "1. Click your the group you wish to administrate." & @CRLF _ & "2. Use the tree menu in the left field to select the machine/user." & @CRLF _ & "3. Select the desired command in the list on the right." & @CRLF _ & "4. Click the Execute button to execute that command" & @CRLF _ & "" & @CRLF & " If you do not wish to make a choice, click the exit button.") Case $msg = $okbutton ; running the checked commands For $i = 1 to $cmdCheckbox[0] If (BitAnd(GUICtrlRead($cmdCheckbox[$i]),$GUI_CHECKED)) Then RunWait($cmd[$i]) Next Case Else EndSelect Wend
LxP Posted October 26, 2005 Posted October 26, 2005 (edited) Welcome to the forums!If you place a MsgBox() displaying the content of the $host variable before these lines:;; Commands $cmd[1] = $binDir & "\vncviewer.exe -connect " & $host & " -password " & $vncPasswd $cmd[2] = $binDir & "\vncviewer.exe -connect " & $host & " -password " & $vncPasswd & " -viewonly" $cmd[3] = $binDir & "\psshutdown.exe -o -f " & $host $cmd[4] = $binDir & "\vncviewer.exe -connect " & $host & " -password " & $vncPasswd & " -viewonly"; filler $cmd[5] = $binDir & "\vncviewer.exe -connect " & $host & " -password " & $vncPasswd & " -viewonly"; fillerthen you will find that $host is not set at that point. There's your problem.What you need to do is ensure that $host is set to the correct value before attempting to use its content in another place. This will require a small amount of code rewriting. Edited October 26, 2005 by LxP
wi1d Posted October 26, 2005 Author Posted October 26, 2005 Thanks alot. I moved the array definitions after host is set and everything works great.
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