gte Posted May 4, 2009 Share Posted May 4, 2009 Does anyone have any idea what I've coded wrong? The box at the bottom is just for me trying to troubleshoot and see the output??? Here is the gui (very very simple) expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form3 = GUICreate("Test Scheduled Task Creation", 370, 291, 1677, 414) $schtaskcreatebutton = GUICtrlCreateButton("Create Task", 144, 64, 91, 73, 0) $cmdfiletext = GUICtrlCreateEdit('', 16, 184, 337, 41, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN)) GUICtrlSetData(1, $cmdfiletext) GUISetState(@SW_SHOW) GUICtrlSetOnEvent($schtaskcreatebutton, "createtask") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd func createtask() $server = 'server' $schtaskusername = 'admin' $schtaskpassword = 'p@ssw1rd' $schtaskfrequency = 'once' $schtaskname = 'Update' $schtaskrunfile = 'd:\temp\updatetask.exe' $schtaskstartime = '08:10:00' $schtaskstartdate = '01/01/2010' ;$schtaskcreate = RunWait('cmd.exe', '%systemroot%\system32\', 'schtasks /create /s ' & '\\' & $server & ' /u ' & $schtaskusername & ' /p ' & $schtaskpassword & ' /ru ' & $schtaskusername & ' /rp ' & $schtaskpassword & ' /sc ' & $schtaskfrequency & ' /tn ' & $schtaskname & ' /tr ' & $schtaskrunfile & ' /ST ' & $schtaskstartime & ' /SD ' & $schtaskstartdate) EndFunc HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
Valuater Posted May 4, 2009 Share Posted May 4, 2009 You can not have GUIGetMsg() working with OnEvent-Mode... GUICtrlSetOnEvent() You will need to go one direction or the other, not both 8) Link to comment Share on other sites More sharing options...
Valuater Posted May 4, 2009 Share Posted May 4, 2009 expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form3 = GUICreate("Test Scheduled Task Creation", 370, 291);, 1677, 414) $schtaskcreatebutton = GUICtrlCreateButton("Create Task", 144, 64, 91, 73, 0) $cmdfiletext_Edit = GUICtrlCreateEdit('', 16, 184, 337, 41, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN)) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $schtaskcreatebutton createtask() EndSwitch WEnd Func createtask() MsgBox(4096, "Test", "test OK ", 5) Return $server = 'server' $schtaskusername = 'admin' $schtaskpassword = 'p@ssw1rd' $schtaskfrequency = 'once' $schtaskname = 'Update' $schtaskrunfile = 'd:\temp\updatetask.exe' $schtaskstartime = '08:10:00' $schtaskstartdate = '01/01/2010' ;$schtaskcreate = RunWait('cmd.exe', '%systemroot%\system32\', 'schtasks /create /s ' & '\\' & $server & ' /u ' & $schtaskusername & ' /p ' & $schtaskpassword & ' /ru ' & $schtaskusername & ' /rp ' & $schtaskpassword & ' /sc ' & $schtaskfrequency & ' /tn ' & $schtaskname & ' /tr ' & $schtaskrunfile & ' /ST ' & $schtaskstartime & ' /SD ' & $schtaskstartdate) EndFunc ;==>createtask there were a couple of errors too! 8) Link to comment Share on other sites More sharing options...
gte Posted May 4, 2009 Author Share Posted May 4, 2009 For anyone that just wants to test it outside of the GUI, here is what I finally got to work Put your own values in of course $server = 'servername' $schtaskusername = 'domain\user' $schtaskpassword = 'password' $schtaskfrequency = 'once' $schtaskname = '"Library list update"'; MAKE SURE THIS POS HAS QUOTES OR A SINGLE WORD NAME!!! I WASTED 2 HOURS BECAUSE OF THIS $schtaskrunfile = 'd:\temp\updatetask.exe' $schtaskstartime = '08:10:00' $schtaskstartdate = '01/01/2010' $val1 = RunWait('schtasks.exe /create /s ' & '\\' & $server & ' /u ' & $schtaskusername & ' /p ' & $schtaskpassword & ' /ru ' & $schtaskusername & ' /rp ' & $schtaskpassword & ' /sc ' & $schtaskfrequency & ' /tn ' & $schtaskname & ' /tr ' & $schtaskrunfile & ' /ST ' & $schtaskstartime & ' /SD ' & $schtaskstartdate, @WindowsDir) HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
gte Posted May 4, 2009 Author Share Posted May 4, 2009 Thanks! Here is what I got to work expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $cmdfiletext = '' $Form3 = GUICreate("Test Scheduled Task Creation", 370, 291, 1677, 414) $schtaskcreatebutton = GUICtrlCreateButton("Create Task", 144, 64, 91, 73, 0) $cmdfiletext = GUICtrlCreateEdit('', 16, 184, 337, 41, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN)) GUICtrlSetData(1, $cmdfiletext) GUISetState(@SW_SHOW) GUICtrlSetOnEvent($schtaskcreatebutton, "createtask") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $schtaskcreatebutton createtask() EndSwitch WEnd func createtask() $server = 'servername' $schtaskusername = 'domain\user' $schtaskpassword = 'password' $schtaskfrequency = 'once' $schtaskname = '"Library list update"'; MAKE SURE THIS POS HAS QUOTES OR A SINGLE WORD NAME!!! I WASTED 2 HOURS BECAUSE OF THIS $schtaskrunfile = 'd:\temp\updatetask.exe' $schtaskstartime = '08:10:00' $schtaskstartdate = '01/01/2010' $val1 = RunWait('schtasks.exe /create /s ' & '\\' & $server & ' /u ' & $schtaskusername & ' /p ' & $schtaskpassword & ' /ru ' & $schtaskusername & ' /rp ' & $schtaskpassword & ' /sc ' & $schtaskfrequency & ' /tn ' & $schtaskname & ' /tr ' & $schtaskrunfile & ' /ST ' & $schtaskstartime & ' /SD ' & $schtaskstartdate, @WindowsDir) EndFunc ---------------------------------- expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form3 = GUICreate("Test Scheduled Task Creation", 370, 291);, 1677, 414) $schtaskcreatebutton = GUICtrlCreateButton("Create Task", 144, 64, 91, 73, 0) $cmdfiletext_Edit = GUICtrlCreateEdit('', 16, 184, 337, 41, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN)) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $schtaskcreatebutton createtask() EndSwitch WEnd Func createtask() MsgBox(4096, "Test", "test OK ", 5) Return $server = 'server' $schtaskusername = 'admin' $schtaskpassword = 'p@ssw1rd' $schtaskfrequency = 'once' $schtaskname = 'Update' $schtaskrunfile = 'd:\temp\updatetask.exe' $schtaskstartime = '08:10:00' $schtaskstartdate = '01/01/2010' ;$schtaskcreate = RunWait('cmd.exe', '%systemroot%\system32\', 'schtasks /create /s ' & '\\' & $server & ' /u ' & $schtaskusername & ' /p ' & $schtaskpassword & ' /ru ' & $schtaskusername & ' /rp ' & $schtaskpassword & ' /sc ' & $schtaskfrequency & ' /tn ' & $schtaskname & ' /tr ' & $schtaskrunfile & ' /ST ' & $schtaskstartime & ' /SD ' & $schtaskstartdate) EndFunc ;==>createtask there were a couple of errors too! 8) HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
gte Posted May 4, 2009 Author Share Posted May 4, 2009 I referenced that before I posted, but I'm guessing I missed something, I'll check again, thanksYou can not have GUIGetMsg() working with OnEvent-Mode... GUICtrlSetOnEvent()You will need to go one direction or the other, not both8) HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script 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