Sunsawe Posted May 7, 2007 Share Posted May 7, 2007 Hi, I'm a very new user of AutoIt and i would like to know if i can use it to create a task in the windows tasks scheduler. Of course i would also like to know what functions i'm supposed to use for that. Thank you all Link to comment Share on other sites More sharing options...
November Posted May 7, 2007 Share Posted May 7, 2007 Hi, I'm a very new user of AutoIt and i would like to know if i can use it to create a task in the windows tasks scheduler. Of course i would also like to know what functions i'm supposed to use for that. Thank you all Hi, You can try to use the AT windows command: Run("AT.exe", @SystemDir, "flags here") Or RunWait("AT.exe", @SystemDir, "flags here") Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 7, 2007 Share Posted May 7, 2007 You should use SCHTASKS.EXE instead of AT.EXE, at least for Windows 2000 and up. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Zoli1972 Posted February 7, 2008 Share Posted February 7, 2008 I have Win2k Prof. No Schtasks command found in commandline. Seems to be that this is onlnly for XP users. Any replacements available? I want to start my hibernating pc on desired time using my own schedule script. Zoli Link to comment Share on other sites More sharing options...
i386 Posted February 7, 2008 Share Posted February 7, 2008 Make sure you are running as an administrator and not just a user. I do believe that schtasks was implemted into the Windows system in some versions of Windows 2000 and above (mostly just the server packages like Windows 2003 Server Edition), I do know that Microsoft is trying to phase out the AT.exe command. If you can't seem to be able to use schtasks.exe then use the AT.exe command. Also, I would do a search for schtasks.exe in the Microsoft KB and see what you can find out there. I know there is alot of help when you search for it in Google. Alot of people as this question constantly. Spoiler "...Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like.My crime is that of outsmarting you, something that you will never forgive me for." --The Mentor "Mess with the best, die like the rest!!" -Hackers "This above all to thine own self be true." -William Shakespeare "Corruption is only as corrupted as the individual makes it out to be." -i386 Link to comment Share on other sites More sharing options...
Zoli1972 Posted February 8, 2008 Share Posted February 8, 2008 Hi, @i386: I am running as an admin. Unfortunately, I was unable to find schtasks.exe on any path in my system (did a file search). You mentioned, I should try AT.exe. I'm not sure wether it has the functionality I want or not. It should start the computer up from hibernating. I didnt find any information about parameters of this command where I would be able to set "startup from hibernating" or like that. I know, that windows scheduler stores the startup-time in the compuer's RTC, and that the later startup procedure is running on BIOS level first. It would be perfect, if I had an AutoIt function that does the same thing without using the windows scheduler. Zoli Link to comment Share on other sites More sharing options...
dabus Posted February 12, 2008 Share Posted February 12, 2008 I had use for that schtasks a few years ago, and it was said that you have to get it from windows xp and do some hex-editing so that it does not notice that if it's not used on xp. And that really works. Link to comment Share on other sites More sharing options...
Squirrely1 Posted February 13, 2008 Share Posted February 13, 2008 I found this VBScript on the forums: expandcollapse popup' This code schedules a task to run every Sunday at 1:30AM. ' --------------------------------------------------------------- ' From the book "Windows Server Cookbook" by Robbie Allen ' Publisher: O'Reilly Media ' ISBN: 0-596-00633-0 ' Book web site: http://rallenhome.com/books/winsckbk/code.html ' --------------------------------------------------------------- const MON = 1 const TUE = 2 const WED = 4 const THU = 8 const FRI = 16 const SAT = 32 const SUN = 64 ' ------ SCRIPT CONFIGURATION ------ strComputer = "." strCommand = "c:\perl\bin\perl.exe c:\scripts\diskchecker.pl" strStartTime = "********013000.000000-240" ' 01:30 EDT 'YYYYMMDDHHMMSS.MMMMMM-/+TZO boolRepeat = TRUE ' Repeat the task periodically intWeekDay = SUN ' Repeat task every Sunday intMonthDay = "" ' Set this if you want the task to repeat monthly boolInteract = FALSE ' Do not interact with the desktop ' ------ END CONFIGURATION --------- set objWMI = GetObject("winmgmts:\\" & strComputer & "") set objNewTask = objWMI.Get("Win32_ScheduledJob") intRC = objNewTask.Create(strCommand, _ strstartTime, _ boolRepeat, _ intWeekDay, _ intMonthDay, _ boolInteract, _ intJobID) if intRC <> 0 then Wscript.Echo "Error creating task: " & intRC else WScript.Echo "Successfully scheduled task." WScript.Echo "JobID: " & intJobID end if Das Häschen benutzt Radar Link to comment Share on other sites More sharing options...
Zoli1972 Posted February 14, 2008 Share Posted February 14, 2008 Cool, nice script. Do you know, if there is an option for automatic startup I can instert in it? I mean, Windows has the option "resume computer from standby" or something like that in it's Schedule creation dialog/wizard, so I think there must be an equivalent thing as a command or an option to that object call the script uses. That's exactly what I need. Zoli Link to comment Share on other sites More sharing options...
Squirrely1 Posted February 15, 2008 Share Posted February 15, 2008 Probably we should do a Google search on this string: Win32_ScheduledJob and look for example scripts. Das Häschen benutzt Radar Link to comment Share on other sites More sharing options...
rover Posted February 15, 2008 Share Posted February 15, 2008 worked this out yesterday when I saw the VB script expandcollapse popupOpt("MustDeclareVars", 1) Opt("TrayIconHide", 1) ;Win32_ScheduledJob Class ;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/Win32_ScheduledJob.asp ;Create Method of the Win32_ScheduledJob Class ;http://msdn2.microsoft.com/en-us/library/aa389389(VS.85).aspx ; The Win32_ScheduledJob class represents a job scheduled using the network management schedule service functions ; (also known as "Job" and "AT command" functions). ; Note that this is different from the tasks scheduled using the Windows 2000 Task Scheduler. ; This class is only instrumented on Windows NT 4.0 and later. ; Each job scheduled against the schedule service is stored persistently ; (the scheduler will know to start the job even after a reboot) ; and is executed at the specified time and day of the week and/or month. ; If the computer is not active or if the scheduled service is not running at the specified job time ; the schedule service will run the specified job on the next day at the specified time. ; Scheduled jobs are scheduled with respect to Universal Coordinated Time (UTC), i.e. with bias offset from GMT. ; This means that a job can be specified using any time zone specification. ; The Win32_ScheduledJob class will return the local time with UTC offset when enumerating an object and convert ; to local time when creating new jobs. ; For example a job specified to run on a computer in Boston at 10:30 pm Monday PST time will be scheduled ; to run locally at 1:30am Tuesday EST. ; It should be noted that a client must take into account whether daylight savings time is in operation on the local computer ; and if so subtract a bias of 60 minutes from the UTC offset. ; This WMI code same as AT.exe ; List jobs programmatically with Win32_ScheduledJob, Caveat: wont list jobs scheduled with schtasks.exe ; Scheduled tasks folder in Winxp displays jobs as 'At1', 'At2' etc. Local $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") Local $objWMIService, $objShare, $objInParam, $objOutParams Local $strComputer = @ComputerName ; "." "localhost" Local $scheduledprog = @SystemDir & "\notepad.exe" Local $time = "1321" ; 24hr Time: 1:20PM Local $tzo = "300" ; Timezone: EST (5 * 60) $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $objShare = $objWMIService.Get("Win32_ScheduledJob") $objInParam = $objShare.Methods_("Create").inParameters.SpawnInstance_() $objInParam.Properties_.Item("Command") = $scheduledprog $objInParam.Properties_.Item("DaysOfMonth") = "" ; only for scheduling repeat events $objInParam.Properties_.Item("DaysOfWeek") = "" ; only for scheduling repeat events $objInParam.Properties_.Item("InteractWithDesktop") = True ; False = Run process as System $objInParam.Properties_.Item("RunRepeatedly") = False ; False = Run one time only $objInParam.Properties_.Item("StartTime") = "********" & $time &"00.000000-" & $tzo ; YYYYMMDDHHMMSS.MMMMMM-/+TZO - cant use Year/Month/Day or Seconds $objOutParams = $objWMIService.ExecMethod("Win32_ScheduledJob", "Create", $objInParam) ConsoleWrite("Out Parameters: " & @CRLF) ConsoleWrite("JobId: " & $objOutParams.JobId & @CRLF) ConsoleWrite("ReturnValue: " & $objOutParams.ReturnValue & @CRLF) Func MyErrFunc() Local $HexNumber = Hex($oMyError.number,8) ConsoleWrite("Debug: Intercepted COM Error: Number = " & $HexNumber & _ " Windescription = " & $oMyError.windescription & @LF) SetError(1) EndfuncoÝ÷ ÚX¬¶:°è¬rZ²K 99b²×jëh×6; Generated by AutoIt Scriptomatic Opt("MustDeclareVars", 1) Local $strComputer = "localhost" Local $colItems = "", $Output="", $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $Output &= "Computer: " & $strComputer & @CRLF $Output &= "==========================================" & @CRLF Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ScheduledJob", "WQL", 0x30) If IsObj($colItems) then For $objItem In $colItems $Output &= "Caption: " & $objItem.Caption & @CRLF $Output &= "Command: " & $objItem.Command & @CRLF $Output &= "DaysOfMonth: " & $objItem.DaysOfMonth & @CRLF $Output &= "DaysOfWeek: " & $objItem.DaysOfWeek & @CRLF $Output &= "Description: " & $objItem.Description & @CRLF $Output &= "ElapsedTime: " & WMIDateStringToDate($objItem.ElapsedTime) & @CRLF $Output &= "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF $Output &= "InteractWithDesktop: " & $objItem.InteractWithDesktop & @CRLF $Output &= "JobId: " & $objItem.JobId & @CRLF $Output &= "JobStatus: " & $objItem.JobStatus & @CRLF $Output &= "Name: " & $objItem.Name & @CRLF $Output &= "Notify: " & $objItem.Notify & @CRLF $Output &= "Owner: " & $objItem.Owner & @CRLF $Output &= "Priority: " & $objItem.Priority & @CRLF $Output &= "RunRepeatedly: " & $objItem.RunRepeatedly & @CRLF $Output &= "StartTime: " & WMIDateStringToDate($objItem.StartTime) & @CRLF $Output &= "Status: " & $objItem.Status & @CRLF $Output &= "TimeSubmitted: " & WMIDateStringToDate($objItem.TimeSubmitted) & @CRLF $Output &= "UntilTime: " & WMIDateStringToDate($objItem.UntilTime) & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_ScheduledJob" ) Endif Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2)) EndFunc Func MyErrFunc() Local $HexNumber = Hex($oMyError.number,8) ConsoleWrite("Debug: Intercepted COM Error: Number = " & $HexNumber & _ " Windescription = " & $oMyError.windescription & @LF) SetError(1) Endfunc I see fascists... Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 15, 2008 Share Posted February 15, 2008 Probably we should do a Google search on this string: Win32_ScheduledJoband look for example scripts.This is why I recommend using SCHTASKS.EXE and not that WMI technique: (quoted from MSDN):Win32_ScheduledJob ClassThe Win32_ScheduledJob WMI class represents a job created with the AT command. The Win32_ScheduledJob class does not represent a job created with the Scheduled Task Wizard from the Control Panel. You cannot change a task created by WMI in the Scheduled Tasks UI.None of these things are problems with SCHTASKS.EXE. It can modify and otherwise act on jobs created in the Scheduled Tasks GUI, and create new job that will be usable through that UI. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Squirrely1 Posted February 15, 2008 Share Posted February 15, 2008 (edited) So Googling Schtasks instead: APPLIES TO Microsoft Windows Server 2003, Datacenter Edition (32-bit x86) Microsoft Windows Server 2003, Enterprise Edition (32-bit x86) Microsoft Windows Server 2003, Standard Edition (32-bit x86) Microsoft Windows Server 2003, Web Edition Microsoft Windows XP Professional for Itanium-based systems Microsoft Windows Small Business Server 2003 Standard Edition Microsoft Windows Small Business Server 2003 Premium Edition Schtasks /Create Creates a new scheduled task. Syntax: schtasks /create/tn TaskName /tr TaskRun /sc schedule [/mo modifier] [/d day] [/m month[,month...] [/i IdleTime] [/st StartTime] [/sd StartDate] [/ed EndDate] [/du duration] [/s computer [/u [domain\]user /p password]] [/ru {[Domain\]User | "System"} [/rp Password]] /?It doesn't look like we have the desired functionality, and it doesn't seem to be available on my version of XP. Someone on the forums found a way to wake on LAN - I have the script but I haven't tried it. Edited February 15, 2008 by Squirrely1 Das Häschen benutzt Radar Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 15, 2008 Share Posted February 15, 2008 So Googling Schtasks instead:It doesn't look like we have the desired functionality, and it doesn't seem to be available on my version of XP. Someone on the forums found a way to wake on LAN - I have the script but I haven't tried it.Yeah, backward compatibility is an issue. It doesn't come with Win2K baseline, but in one of the service packs or resource kits for that. Since I have multiple server versions running around here, I just use the Win2K3 copy and it works with everything I have (Win2K SP4 minimum). Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Frank99 Posted April 2, 2008 Share Posted April 2, 2008 I have just tried to copy the schtasks.exe (File-Version 5.2.3790.0) from one of my Win 2003 Server Installations to a Server running Win 2000 Server (SP4), but this one does not run. I get a error message " ERROR: The target system must be running Windows XP or above." So what version of schtasks do you use or do I need to copy more files in order to get the schtasks.exe running on my W2K Server ? Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 2, 2008 Share Posted April 2, 2008 I have just tried to copy the schtasks.exe (File-Version 5.2.3790.0) from one of my Win 2003 Server Installations to a Server running Win 2000 Server (SP4), but this one does not run. I get a error message " ERROR: The target system must be running Windows XP or above."So what version of schtasks do you use or do I need to copy more files in order to get the schtasks.exe running on my W2K Server ?It's included in the Win2K resource kit from M$. I'm pretty sure I just used the copy from one of my Win2K3 SP1 servers, and it worked. Problem is, the Win2K servers have since been rebuilt with Win2K3, so I can't go back and prove it now. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted April 5, 2008 Share Posted April 5, 2008 you could use jt.exe http://windowsitpro.com/article/articleid/...ne-utility.htmlit works on NT4/W2K/W2K3 , W2K8 not yet tested Best regards,Emiel Wieldraaijer 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