oneLess Posted September 17, 2012 Share Posted September 17, 2012 thank you for the script Allow2010 .i working on a project these day , who basically disable unwanted things loaded on startup , especially updaters .i solved my needs for windows xp using the old microsoft jt.exe (referring here only for the scheduled tasks part)but , in windows seven my script dont work properly.i try to change/complete your script , but probaly i do not find/apply the right methods and/or properties .i cant find much info on the net for theese .if dont want bother yoy , but some new functions likeFunc _TaskEnable($taskname, $folder = ""); enable a TaskFunc _TaskDisable($taskname, $folder = ""); disable a TaskFunc _TaskCheckIsEnabled($taskname, $folder = "");check if a Task is enabledcan help me and other when i finish/publish my projecti suppose all 3 function will set/check$oSettings.Enabled() = $active ;True ; The task can be performed only when this setting is True..thank you !oneLess Link to comment Share on other sites More sharing options...
oneLess Posted September 17, 2012 Share Posted September 17, 2012 Func _TaskEnable($taskname, $folder = ""); enable a TaskFunc _TaskDisable($taskname, $folder = ""); disable a TaskFunc _TaskCheckIsEnabled($taskname, $folder = "");check if a Task is enabled i found the right property here : http://msdn.microsoft.com/en-us/library/windows/desktop/aa380757(v=vs.85).aspx $oTask.Enabled = False ; [= 0 , will disable the task] $oTask.Enabled = True ; [=-1 , will enable the task] $_a = $oTask.Enabled ; [will read the status of the task , 0=False=Disabled , -1=True=Enabled] more options in reading of status here : http://msdn.microsoft.com/en-us/library/windows/desktop/aa380770(v=vs.85).aspx $oTask.State is the property ; [TASK_STATE_DISABLED = 1 = Disabled] oneLess Link to comment Share on other sites More sharing options...
Allow2010 Posted November 22, 2012 Author Share Posted November 22, 2012 after a long time i checked this tread and i thank everybody for the comments and ideas... I will try to update the UDF and if someone has done some of those modifications already or has other useful hints, please post here soon, so i do not have to do something that is already done:-)) Link to comment Share on other sites More sharing options...
Allow2010 Posted November 22, 2012 Author Share Posted November 22, 2012 Looks like a useful UDF Allow2010. Thanks A very small suggestion: The _TaskCreate function has a dayof month parameter which has to be some power of 2. It would be easier (for me at least) if this parameter were just the actual day of the month. To keep it compatible with previous versions you could say that if a negative value is used it means the actual day number (1 - 31). Use -32 for "last day". Then in the function you could have if $DaysOfMonth < 0 then $DaysOfMonth = 2^(-$DaysOfMonth - 1) maybe i get it wrong: when i want to set day 10 and day 11 for a task to run i will combine 512+1024=1536 If i use real day numbers like -10 + -11 = -21 and then do $DaysOfMonth = 2^(-$DaysOfMonth - 1) 2^(- (-21) -1)= 2^20= 1048576 this will not work?! Link to comment Share on other sites More sharing options...
Allow2010 Posted November 22, 2012 Author Share Posted November 22, 2012 I am impressed with your UDF and I think it is much better than schtasks.exe I want to create a daily task, whichstarts at 6:30repeats every 6 hours, for a duration of one dayAt the moment I can create a daily task which starts at 6:30, repeats every 6 hours but indefinately. I would like to change that to a duration of one day if possible? _TaskCreate("Smart-NetSmartRAS Monitor Script", "Report in info about the Smart-RAS to SNID", 2, "2000-01-01T06:30:00", "", "", "", "", "", 1, "PT6H", True, 1, 0, $username,$password, """"&$app&"""", "", "", False, True,0,True,True,False,False,False,"P3D",5) EDIT Have modified the UDF to support $Duration If $RepetitionEnabled Then $oTriggerRepetition = $oTrigger.Repetition() $oTriggerRepetition.Interval() = $Interval $oTriggerRepetition.Duration() = $Duration EndIf Now I am running this code to do what I need _TaskCreate("Smart-NetSmartRAS Monitor Script", "Report in info about the Smart-RAS to SNID", 2, "2000-01-01T06:30:00", "", "", "", "", "", 1, "PT6H","P1D", True, 1, 0, $username,$password, """"&$app&"""", "", "", False, True,0,True,True,False,False,False,"P3D",5) Thanks for the code, its extremely useful. BTW if others want to modify the code I recommend using powershell script here to enumerate the schedule task objects i implented you changes, but duration was added to the end of the paramter list for taskcreate in order to not break compatibillity... Thanks! Link to comment Share on other sites More sharing options...
Allow2010 Posted November 22, 2012 Author Share Posted November 22, 2012 (edited) Just came across this today and have to say very impressive. Thanks for posting it. There is room for improvement e.g. _TaskSchedulerAutostart() can be consolidated into one line or three if you count Func and EndFunc. Func _TaskSchedulerAutostart() Return RegRead("HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesSchedule", "Start") > 0 ; Returns True or False. EndFunc ;==>_TaskSchedulerAutostart You are right, i know a lot of my code can be more elegant, but for me, most important is that i and all others can read it well, even after months :-) Edited November 22, 2012 by Allow2010 Link to comment Share on other sites More sharing options...
Allow2010 Posted November 22, 2012 Author Share Posted November 22, 2012 i found the right property here : http://msdn.microsoft.com/en-us/library/windows/desktop/aa380757(v=vs.85).aspx $oTask.Enabled = False ; [= 0 , will disable the task] $oTask.Enabled = True ; [=-1 , will enable the task] $_a = $oTask.Enabled ; [will read the status of the task , 0=False=Disabled , -1=True=Enabled] more options in reading of status here : http://msdn.microsoft.com/en-us/library/windows/desktop/aa380770(v=vs.85).aspx $oTask.State is the property ; [TASK_STATE_DISABLED = 1 = Disabled] oneLess Thanks, will be included, but _TaskCheckIsEnabled will be _TaskIsEnabled Link to comment Share on other sites More sharing options...
guinness Posted November 22, 2012 Share Posted November 22, 2012 You are right, i know a lot of my code can be more elegant, but for me, most important is that i and all others can read it well, even after months :-)I agree, this is what it's good to use comments instead. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Allow2010 Posted November 22, 2012 Author Share Posted November 22, 2012 Updated first post with new Version of UDF. Should be fully compatible with old version so no code changes should be needed... Link to comment Share on other sites More sharing options...
Allow2010 Posted November 25, 2012 Author Share Posted November 25, 2012 Added version without COM Errorhandler Link to comment Share on other sites More sharing options...
Allow2010 Posted December 31, 2012 Author Share Posted December 31, 2012 (edited) added version 5.2 with new TaskCreate option $startwhenavailable only the version without com error handler will be updated...i recommend to use only this version. Edited January 2, 2013 by Allow2010 Link to comment Share on other sites More sharing options...
ModemJunki Posted March 28, 2013 Share Posted March 28, 2013 Allow2010, thank you very much for this work! I was trying to make an script with schtasks.exe and had some odd results, after 30 minutes I came here and found this and then in ~5 minutes my script was finished. Always carry a towel. Link to comment Share on other sites More sharing options...
Allow2010 Posted July 25, 2013 Author Share Posted July 25, 2013 thanks for the feedback ! Link to comment Share on other sites More sharing options...
NDog Posted September 3, 2013 Share Posted September 3, 2013 I am trying to create a scheduled task as SYSTEM user under Windows 8 but not having any luck. Could you fix my script? #include <CCBtaskplanerudf.au3> #RequireAdmin $program = "C:\Windows\Setup\scripts\profile\LUService.exe" If @OSVersion = "WIN_2003" Or @OSVersion = "WIN_XP" Or @OSVersion = "WIN_XPe" Or @OSVersion = "WIN_2000" Then MsgBox(0,"Error", @ScriptName & " is not supported on NT5 platforms") Exit ElseIf @OSVersion = "WIN_2008R2" Or @OSVersion = "WIN_7" Or @OSVersion = "WIN_8" Or @OSVersion = "WIN_2008" Then $result = _TaskCreate("LU Service","Loop Users Service",8,"","","","","","","","","","",2,1,"SYSTEM","",""""&$program&"""","","",False,True,2,False,False,False,False,False,False,"P3D",5) ConsoleWrite("$result: "& $result & @CRLF) If $result = 1 Then MsgBox(0, "Success", "LUService was installed successfully",5) Else MsgBox(32, "Failure", "LUService was not installed successfully") EndIf EndIf Link to comment Share on other sites More sharing options...
jaberwacky Posted September 3, 2013 Share Posted September 3, 2013 (edited) From what I could tell $RunLevel takes either a 0 or 1. You have passed "SYSTEM" instead. Edit: Scratch that actually. I think I was off by one parameter. It does look like your paramters are off. I'm pretty that that you give $RunLevel a 2 when it does take 0 or 1. Edited September 3, 2013 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
jaberwacky Posted September 3, 2013 Share Posted September 3, 2013 (edited) I have arranged them like this to make it easier to follow. I hope the forum preserves the formatting. Edit: Ok, looks like you're giving it one too many arguments. _TaskCreate("LU Service", "Loop Users Service", 8, _ "", "", "", _ "", "", "", _ "", "", "", _ "", 2, 1, _ "SYSTEM", "", """" & $program & """", _ "", "", False, _ True, 2, False, _ False, False, False, _ False, False, "P3D", _ 5) Func _TaskCreate($taskname, $TaskDescription, $TriggerEvent, _ $StartTrigger, $EndTrigger, $DaysOfWeek, _ $DaysOfMonth, $MonthOfYear, $WeeksOfMonth, _ $DaysInterval, $Interval, $RepetitionEnabled, _ $LogonType, $RunLevel, $username, _ $password, $program, $WorkingDirectory = "", _ $Arguments = "", $RunOnlyIfNetworkAvailable = True, $active = True, _ $multiinst = 0, $nobatstart = False, $stoponBat = False, _ $hidden = False, $idle = False, $WakeToRun = False, _ $timelimit = "P1D", $priority = 5, $Duration = "") Edited September 3, 2013 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Allow2010 Posted November 9, 2013 Author Share Posted November 9, 2013 (edited) FYI: it seems that the UDF is not working with betas 3.3.9.10 and above. I found out that beta 3.3.9.9 works fine, but 3.3.9.10 and all later betas fail. the changelog does not help: 3.3.9.10 (21 July, 2013) (Beta) AutoIt: - Changed: #NoAutoItExecute option replaced with #pragma compile(AutoItExecuteAllowed, true). Default is false. - Fixed #2286 GuiCtrtlGetState without a controlID parameter runs but aborts AutoIt. - Fixed #2350 Strange issue when using $SS_ETCHEDVERT and $SS_ETCHEDHORZ. Aut2Exe: - Changed: Compiling uses a subfolder of %localappdata% instead of %temp% for temporary files. Hopefully this fixes warnings from over-zealous AV. 3.3.9.9 (19 July, 2013) (Beta) AutoIt: - Added: FuncName(). - Fixed: Subtle bugs with Ping() Aut2Exe: - Changed: FileInstall() files are now stored in the Resources section along with the script. No overlays are used anymore. - Changed: Default changed to not use UPX. UDFs: - Added: Example for _VersionCompare. - Fixed #2320: Incorrect return values for certain IE functions. any idea what i could do here? Edited November 9, 2013 by Allow2010 Link to comment Share on other sites More sharing options...
BrewManNH Posted November 9, 2013 Share Posted November 9, 2013 "Not working" is a bit vague of a problem description. Do you get an error? Does it run at all? Does it not pass Au3Check? What exactly isn't working? 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 GudeHow 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 More sharing options...
Allow2010 Posted November 9, 2013 Author Share Posted November 9, 2013 Oh, i think i tricked my self:-) Func _TaskIsValidPlatfrom() If @OSVersion = "WIN_XP" Or @OSVersion = "WIN_XPe" Or @OSVersion = "WIN_2000" Or @AutoItVersion < "3.3.9.4" Then ;win Vusta or newer and Autoit 3.3.9.4 needed for this uDF to work Return 0 Else Return 1 EndIf EndFunc ;==>_TaskIsValidPlatfrom I think this will fail when the version is 3.3.9.10 10 compares as < 4 because the 1 in 10 is compared... oh man stupid me... Link to comment Share on other sites More sharing options...
guinness Posted November 9, 2013 Share Posted November 9, 2013 You should be using _VersionCompare(). UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 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