Jump to content

Search the Community

Showing results for tags 'schtasks'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Location


WWW


Interests

Found 5 results

  1. I am attempting to run an Autoit.exe with schtasks every weekday @ 9:05 am. I have the below C:\>SchTasks /Create /TN "P10Run" /TR "O:\AUTOIT\P40 Run.au3" /SC WEEKLY /D MON, TUE,WED,THU,FRI /ST 09:05:00 SUCCESS: The scheduled task "P10Run" has successfully been created. I also did a "test" run : C:\>Schtasks /Run /TN "P10Run SUCCESS: Attempted to run the scheduled task "P10Run". But when I run my query to verify success my "Last Result" seems to indicate that the script did not run: C:\>SCHTASKS /QUERY /FO LIST /V /TN "P10RUN" Folder: \ HostName: xxxxxxxxxxxxxxxx TaskName: \P10RUN Next Run Time: N/A Status: Could not start Logon Mode: Interactive only Last Run Time: 6/14/2017 9:08:56 AM Last Result: -2147024894 Author: xxxxxxx Task To Run: O:\AUTOIT\P40 Run.au3 Start In: N/A Comment: N/A Scheduled Task State: Enabled Idle Time: Disabled Power Management: Stop On Battery Mode, No Start On Batterie s Run As User: xxxxxxxxx\xxxxxxxx Delete Task If Not Rescheduled: Enabled Stop Task If Runs X Hours and X Mins: 72:00:00 Schedule: Scheduling data is not available in this f ormat. Schedule Type: Weekly Start Time: 9:05:00 AM Start Date: 6/14/2017 End Date: N/A Days: MON, TUE, WED, THU, FRI Months: Every 1 week(s) Repeat: Every: Disabled Repeat: Until: Time: Disabled Repeat: Until: Duration: Disabled Repeat: Stop If Still Running: Disabled C:\> Is there something missing in my command? Also is there a better way to make sure that the script does in fact sun successfully? Thanks In Advance!
  2. I have this button in an app I am building: When you click it, it then opens a FileOpenDialog() I select and XML, then it asks for a name input, enter the name, then it should run the following code: schtasks.exe /create /tn XXXX-task /XML C:\WBRESO~1\WB-LOO~1\TESTIN~1.XML It works when I put it in the CMD and run it, I get SUCCESS! and the new task has been created in Task Scheduler. C:\Users\vivaed>schtasks.exe /create /tn XXXX /xml C:\WBRESO~1\WB-LOO~1\TESTIN~1.XML SUCCESS: The scheduled task "XXXX" has successfully been created. But when I run it in: (This is just a snippet of the code, there is a lot more) #include <AutoItConstants.au3> Global $wbResources = 'C:\"WB Resources"\WB-LoopChecker\' Case $Button4 $getXML = FileOpenDialog("Find task to import", $wbResources ,"XML (*.xml)") If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file was selected.") Else Local $taskName = InputBox("Name this task","File: " & @CRLF & $getXML & @CRLF & "Name this task:" & @CRLF,"XXXX-task") $schedTask = 'schtasks.exe /create /tn ' & $taskName & ' /XML ' & FileGetShortName($getXML) Run(@ComSpec & " /c " & $schedTask, @SW_HIDE) ConsoleWrite($wbResources & @CRLF) ConsoleWrite($schedTask & @CRLF) EndIf Here I dont get any errors but the when I refresh the Task Scheduler, there is no new task....
  3. I'm attempting to created a windows task using SCHTASKS, but seem to have my formatting incorrect as a double quote is getting stripped out. How might I correct my code to resolve this dilemma? #RequireAdmin #include <AutoItConstants.au3> Global $TaskName, $sStartTime, $Program, $ProgramName, $Argument $TaskName = "MyTask" $sStartTime = "15:00" $ProgramName = "\\Server\share\myapp.exe" $Argument = " /verbose" $Program = '"' & $ProgramName & '"' & $Argument & '"' MsgBox(0, "Program with Argument", $Program) Scheduler() Func Scheduler() Local $sCmd, $sStartDate, $sDateTime, $sXtra_Parms, $Result Local $QueryTask = Run("SCHTASKS /QUERY /TN " & $TaskName, "", @SW_HIDE, $STDOUT_CHILD) Local $line = "" If @OSVersion = "WIN_VISTA" Or @OSVersion = "WIN_7" Or @OSVersion = "WIN_8" Or @OSVersion = "WIN_81" Then $sXtra_Parms = " /Z /V1" While 1 $line &= StdoutRead($QueryTask) If @error Then ExitLoop WEnd If $line = "" Then MsgBox(1, "Task Command", 'SCHTASKS /CREATE /TN ' & $TaskName & ' /TR ' & '"' & $Program & '"' & ' /ST ' & $sStartTime & ' /SC ONCE /RU SYSTEM' & $sXtra_Parms) $sCmd = 'SCHTASKS /CREATE /TN ' & $TaskName & ' /TR ' & '"' & $Program & '"' & ' /ST ' & $sStartTime & ' /SC ONCE /RU SYSTEM' & $sXtra_Parms ;$sCmd = 'SCHTASKS /CREATE /TN ' & $TaskName & ' /TR ' & $Program & ' /ST ' & $sStartTime & ' /SC ONCE /RU SYSTEM' & $sXtra_Parms Else $sCmd = 'SCHTASKS /CHANGE /TN ' & $TaskName & ' /ST ' & $sStartTime EndIf $Result = Run($sCmd, "", @SW_HIDE) If $Result > 0 Then MsgBox(64, "Success!!", "The task was successfully created.") Else MsgBox(48, "Sorry...", "There was a problem scheduling this installation, please contact the HelpDesk for assistance.") EndIf EndFunc ;==>Scheduler The task is created with the above code, except the formatting is wrong so I getting an invalid directory error upon run time. The above creates this command (Serversharemyapp.exe" /verbose) in the task scheduler. What I'm actually trying to get is ("Serversharemyapp.exe" /verbose) The first double quote is being stripped out using my faulty code. Any suggestions? Thanks for your time, -Mike
  4. So I apologize in advance for the horrible mess you see below. While there may be many issues with my code, I only need help with one part. This GUI is an interface for customers to install software pushed via SCCM. While I have Continue and Abort buttons working just fine, I'm trying to implement a scheduler that will allow the customer to defer the install for later in the day up until 11:30pm. I'd like to have the combobox display the current time (12 hour format) and then all hours (both top and bottom of the hour) until 11:30pm. So if they check the "Defer" box, select a time from the dropdown (such as 8:30pm) and click "Go"...the time chosen will be sent to my 'unfinished' Scheduler function which will then create a task to be executed at the specified time. I hope that all makes some sense. So again, the only thing I would like some help with is how to correctly create the combobox with the possible values based on the current local time. I should be able to figure out the rest. Thanks for any suggestions, -Mike Edit:...Oops, if the moderator would like to move this post to the "Graphical User Interface (GUI) Help and Support", I wasn't thinking when I hit submit...sorry. #include "_XMLDomWrapper.au3" #include <Constants.au3> #include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Date.au3> ;Global $sFile = (@ScriptDir & "\Config.xml") Global $hGUI, $FormTitle, $RTFName, $ProgramName, $TrayTip, $ShutdownTimer, $ParamName, $AbortAllowed, $AbortButtonName, $ContinueButtonName, $GoButton, $Scheduler Global $hRichEdit, $ExitCode, $Width, $Height, $sHours If @DesktopWidth > 1024 Then $Width = 1024 Else $Width = @DesktopWidth EndIf If @DesktopHeight > 768 Then $Height = 768 Else $Height = @DesktopHeight EndIf ;_XMLFileOpen($sFile) $FormTitle = _XMLGetAttrib("/MessageInfo/Title", "FormTitle") $RTFName = _XMLGetAttrib("/MessageInfo/Display", "RTFName") $ProgramName = _XMLGetAttrib("/MessageInfo/Program", "ProgramName") $TrayTip = _XMLGetAttrib("/MessageInfo/TrayTip", "TrayTip") $ShutdownTimer = _XMLGetAttrib("/MessageInfo/ShutdownTimer", "ShutdownTimer") $ParamName = _XMLGetAttrib("/MessageInfo/Param", "ParamName") $AbortAllowed = _XMLGetAttrib("/MessageInfo/Abort", "AbortAllowed") $AbortButtonName = _XMLGetAttrib("/MessageInfo/ABN", "AbortButtonName") $ContinueButtonName = _XMLGetAttrib("/MessageInfo/CBN", "ContinueButtonName") $Scheduler = _XMLGetAttrib("/MessageInfo/Sched", "Scheduler") _Main() ; Functions Func _Main() Local $msg, $AbortButton, $ContinueButton, $ScheduleBox $hGUI = GUICreate($FormTitle, $Width - 20, $Height - 100, -1, 10, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGUI, "", 10, 10, $Width - 40, $Height - 150, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) ;GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") _GUICtrlRichEdit_SetEventMask($hRichEdit, $ENM_LINK) _GUICtrlRichEdit_AutoDetectURL($hRichEdit, True) $ContinueButton = GUICtrlCreateButton($ContinueButtonName, $Width - 500, $Height - 133, 100, 25) GUICtrlSetFont($ContinueButton, 10, 800, 0, "Tahoma") $AbortButton = GUICtrlCreateButton($AbortButtonName, $Width - 390, $Height - 133, 100, 25) GUICtrlSetFont($AbortButton, 10, 800, 0, "Tahoma") $ScheduleBox = GUICtrlCreateCheckbox("Defer", $Width - 280, $Height - 133, 75, 25) GUICtrlSetFont($ScheduleBox, 10, 800, 0, "Tahoma") Global $hCombo = GUICtrlCreateCombo("", $Width - 200, $Height - 132, 90, 25) GUICtrlSetData(-1, @HOUR + 1 & "|" & @HOUR + 2 & "|" & @HOUR + 3 & "|" & @HOUR + 4 & "|" & @HOUR + 5 & "|" & @HOUR + 6 & "|" & @HOUR + 7 & "|" & @HOUR + 8) $GoButton = GUICtrlCreateButton("Go", $Width - 75, $Height - 133, 50, 25) GUICtrlSetFont($GoButton, 10, 800, 0, "Tahoma") GUISetState() _GUICtrlRichEdit_StreamFromFile($hRichEdit, $RTFName) _GUICtrlRichEdit_SetReadOnly($hRichEdit) _GUICtrlRichEdit_GotoCharPos($hRichEdit, 0) MouseClick("main", @DesktopWidth / 2, @DesktopHeight / 2, 0) Sleep(1000) ;GUISetState(@SW_MINIMIZE) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $ContinueButton Opt("TrayIconHide", 1) GUISetState(@SW_HIDE) $ExitCode = RunWait(@ScriptDir & "\" & $ProgramName) _GUICtrlRichEdit_Destroy($hRichEdit) ;MsgBox(0, "Program Exit Code", $ExitCode) Exit $ExitCode Case $msg = $GoButton Opt("TrayIconHide", 1) GUISetState(@SW_HIDE) ;Scheduler() _GUICtrlRichEdit_Destroy($hRichEdit) Exit Case $msg = $GUI_EVENT_CLOSE Or $msg = $AbortButton _GUICtrlRichEdit_Destroy($hRichEdit) Exit -1 EndSelect WEnd EndFunc ;==>_Main ;~ Func Scheduler() ;~ Local $sXtra_Parms ;~ Local $sDateTime = _DateAdd('h', $sHours, _NowCalc()) ;~ Local $sStartDate = StringMid($sDateTime, 6, 3) & StringMid($sDateTime, 9, 2) & "/" & StringLeft($sDateTime, 4) ;~ $sStartTime = StringRight($sDateTime, 8) ;~ If @OSVersion = "WIN_VISTA" Or @OSVersion = "WIN_7" Or @OSVersion = "WIN_8" Then $sXtra_Parms = " /Z /V1" ;~ Local $QueryTask = Run("SCHTASKS /QUERY /TN " & $FormTitle, "", @SW_HIDE, $STDOUT_CHILD) ;~ Local $line = "" ;~ While 1 ;~ $line &= StdoutRead($QueryTask) ;~ If @error Then ExitLoop ;~ WEnd ;~ If $line = "" Then ;~ $sCmd = 'SCHTASKS /CREATE /SC ONCE /TN ' & $FormTitle & ' /TR ' & $ProgramName & ' /SD ' & $sStartDate & ' /ST ' & $sStartTime & ' /RU SYSTEM' & $sXtra_Parms ;~ Run($sCmd, "", @SW_HIDE) ;~ ;MsgBox(0, "", $sCmd) ; for testing ;~ Else ;~ $sCmd = 'SCHTASKS /CHANGE /TN ' & $FormTitle & ' /SD ' & $sStartDate & ' /ST ' & $sStartTime ;~ Run($sCmd, "", @SW_HIDE) ;~ ;MsgBox(0, "", $sCmd) ; for testing ;~ EndIf ;~ EndFunc ;==>Scheduler Here is the Config.xml file if you're interested. <?xml version="1.0"?> <MessageInfo> <Title FormTitle="EMET 4.1"/> <Display RTFName="RichText.rtf"/> <Program ProgramName="Emet installer.exe /sccm"/> <TrayTip TrayTip="EMET 4.1 Available"/> <ShutdownTimer ShutdownTimer="300000"/> <Param ParamName=""/> <Abort AbortAllowed="Y" /> <ABN AbortButtonName="Not Now"/> <CBN ContinueButtonName="Continue"/> <Sched Scheduler="0"/> </MessageInfo>
  5. So this is fairly simple. I have this command to reboot at 11:30 PM Run('schtasks /create /tn Reboot /tr "shutdown /r /t 120" /sc once /st 23:30:00 /ru %COMPUTER%\Administrator /rp ******') The code works in CMD and AutoIT But the problem is that when run via autoit it schedules it as the logged in user NOT the computer admin (weird) and therefore fails to run. The reason I schedule it as admin is we are on domain and you need to type the user password to schdual a task - but we don't know the password. If I use the DOMAIN admin in the script the task will schedual as domain admin and run - but I dont really feel comfortable putting the domain admin password into a script.
×
×
  • Create New...