├── .gitattributes ├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── TaskSched.sln ├── TaskSched ├── AboutDlg.cpp ├── AboutDlg.h ├── ComHelper.h ├── Icons │ ├── Cancel.ico │ ├── Database.ico │ ├── Delete.ico │ ├── Find.ico │ ├── Folder.ico │ ├── Go.ico │ ├── OK.ico │ ├── Pause.ico │ ├── Period end.ico │ ├── Properties.ico │ ├── Schedule - disabled.ico │ ├── Schedule.ico │ ├── Timer.ico │ ├── action.ico │ ├── app.ico │ ├── back.ico │ ├── bullet.ico │ ├── copy.ico │ ├── folder-open.ico │ ├── forward.ico │ ├── refresh.ico │ ├── stop.ico │ └── up.ico ├── MainFrame.cpp ├── MainFrame.h ├── SecurityHelper.cpp ├── SecurityHelper.h ├── TaskGeneralPage.cpp ├── TaskGeneralPage.h ├── TaskHelper.cpp ├── TaskHelper.h ├── TaskSched.cpp ├── TaskSched.h ├── TaskSched.rc ├── TaskSched.vcxproj ├── TaskSched.vcxproj.filters ├── packages.config ├── pch.cpp ├── pch.h ├── resource.h └── targetver.h └── TaskSched1.png /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "WTLHelper"] 2 | path = WTLHelper 3 | url = https://github.com/zodiacon/WTLHelper 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Pavel Yosifovich 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TaskSched 2 | 3 | View Task Scheduler tasks 4 | 5 | ![](https://github.com/zodiacon/TaskSched/blob/master/TaskSched1.png) 6 | -------------------------------------------------------------------------------- /TaskSched.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.31430.40 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TaskSched", "TaskSched\TaskSched.vcxproj", "{9DEC5985-367E-4504-9E18-06D116F6475E}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WTLHelper", "WTLHelper\WTLHelper.vcxproj", "{AE53419F-A769-4548-8E15-E311904DF7DF}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|ARM64 = Debug|ARM64 13 | Debug|x64 = Debug|x64 14 | Debug|x86 = Debug|x86 15 | Release|ARM64 = Release|ARM64 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {9DEC5985-367E-4504-9E18-06D116F6475E}.Debug|ARM64.ActiveCfg = Debug|x64 21 | {9DEC5985-367E-4504-9E18-06D116F6475E}.Debug|ARM64.Build.0 = Debug|x64 22 | {9DEC5985-367E-4504-9E18-06D116F6475E}.Debug|x64.ActiveCfg = Debug|x64 23 | {9DEC5985-367E-4504-9E18-06D116F6475E}.Debug|x64.Build.0 = Debug|x64 24 | {9DEC5985-367E-4504-9E18-06D116F6475E}.Debug|x86.ActiveCfg = Debug|Win32 25 | {9DEC5985-367E-4504-9E18-06D116F6475E}.Debug|x86.Build.0 = Debug|Win32 26 | {9DEC5985-367E-4504-9E18-06D116F6475E}.Release|ARM64.ActiveCfg = Release|x64 27 | {9DEC5985-367E-4504-9E18-06D116F6475E}.Release|ARM64.Build.0 = Release|x64 28 | {9DEC5985-367E-4504-9E18-06D116F6475E}.Release|x64.ActiveCfg = Release|x64 29 | {9DEC5985-367E-4504-9E18-06D116F6475E}.Release|x64.Build.0 = Release|x64 30 | {9DEC5985-367E-4504-9E18-06D116F6475E}.Release|x86.ActiveCfg = Release|Win32 31 | {9DEC5985-367E-4504-9E18-06D116F6475E}.Release|x86.Build.0 = Release|Win32 32 | {AE53419F-A769-4548-8E15-E311904DF7DF}.Debug|ARM64.ActiveCfg = Debug|ARM64 33 | {AE53419F-A769-4548-8E15-E311904DF7DF}.Debug|ARM64.Build.0 = Debug|ARM64 34 | {AE53419F-A769-4548-8E15-E311904DF7DF}.Debug|x64.ActiveCfg = Debug|x64 35 | {AE53419F-A769-4548-8E15-E311904DF7DF}.Debug|x64.Build.0 = Debug|x64 36 | {AE53419F-A769-4548-8E15-E311904DF7DF}.Debug|x86.ActiveCfg = Debug|Win32 37 | {AE53419F-A769-4548-8E15-E311904DF7DF}.Debug|x86.Build.0 = Debug|Win32 38 | {AE53419F-A769-4548-8E15-E311904DF7DF}.Release|ARM64.ActiveCfg = Release|ARM64 39 | {AE53419F-A769-4548-8E15-E311904DF7DF}.Release|ARM64.Build.0 = Release|ARM64 40 | {AE53419F-A769-4548-8E15-E311904DF7DF}.Release|x64.ActiveCfg = Release|x64 41 | {AE53419F-A769-4548-8E15-E311904DF7DF}.Release|x64.Build.0 = Release|x64 42 | {AE53419F-A769-4548-8E15-E311904DF7DF}.Release|x86.ActiveCfg = Release|Win32 43 | {AE53419F-A769-4548-8E15-E311904DF7DF}.Release|x86.Build.0 = Release|Win32 44 | EndGlobalSection 45 | GlobalSection(SolutionProperties) = preSolution 46 | HideSolutionNode = FALSE 47 | EndGlobalSection 48 | GlobalSection(ExtensibilityGlobals) = postSolution 49 | SolutionGuid = {F073A663-0C39-49F8-8764-C90E0B7B57F4} 50 | EndGlobalSection 51 | EndGlobal 52 | -------------------------------------------------------------------------------- /TaskSched/AboutDlg.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "resource.h" 3 | #include "AboutDlg.h" 4 | 5 | LRESULT CAboutDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { 6 | CenterWindow(GetParent()); 7 | 8 | return TRUE; 9 | } 10 | 11 | LRESULT CAboutDlg::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { 12 | EndDialog(wID); 13 | return 0; 14 | } 15 | 16 | LRESULT CAboutDlg::OnClickSyslink(int, LPNMHDR, BOOL&) const { 17 | ::ShellExecute(nullptr, L"open", L"https://github.com/zodiacon/tasksched", nullptr, nullptr, SW_SHOWDEFAULT); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /TaskSched/AboutDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CAboutDlg : public CDialogImpl { 4 | public: 5 | enum { IDD = IDD_ABOUTBOX }; 6 | 7 | BEGIN_MSG_MAP(CAboutDlg) 8 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 9 | COMMAND_ID_HANDLER(IDOK, OnCloseCmd) 10 | COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd) 11 | NOTIFY_CODE_HANDLER(NM_CLICK, OnClickSyslink) 12 | NOTIFY_CODE_HANDLER(NM_RETURN, OnClickSyslink) 13 | END_MSG_MAP() 14 | 15 | // Handler prototypes (uncomment arguments if needed): 16 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 17 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 18 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) 19 | 20 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 21 | LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 22 | LRESULT OnClickSyslink(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) const; 23 | }; 24 | -------------------------------------------------------------------------------- /TaskSched/ComHelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct ComHelper { 4 | template 5 | static void DoForeach(TCollection* coll, std::function f) { 6 | LONG count; 7 | coll->get_Count(&count); 8 | for (LONG i = 1; i <= count; i++) { 9 | CComPtr spItem; 10 | coll->get_Item(CComVariant(i), &spItem); 11 | if (spItem) 12 | f(spItem.p); 13 | } 14 | } 15 | 16 | template 17 | static void DoForeachNoVariant(TCollection* coll, std::function f) { 18 | LONG count; 19 | coll->get_Count(&count); 20 | for (LONG i = 1; i <= count; i++) { 21 | CComPtr spItem; 22 | coll->get_Item(i, &spItem); 23 | if (spItem) 24 | f(spItem.p); 25 | } 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /TaskSched/Icons/Cancel.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/Cancel.ico -------------------------------------------------------------------------------- /TaskSched/Icons/Database.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/Database.ico -------------------------------------------------------------------------------- /TaskSched/Icons/Delete.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/Delete.ico -------------------------------------------------------------------------------- /TaskSched/Icons/Find.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/Find.ico -------------------------------------------------------------------------------- /TaskSched/Icons/Folder.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/Folder.ico -------------------------------------------------------------------------------- /TaskSched/Icons/Go.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/Go.ico -------------------------------------------------------------------------------- /TaskSched/Icons/OK.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/OK.ico -------------------------------------------------------------------------------- /TaskSched/Icons/Pause.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/Pause.ico -------------------------------------------------------------------------------- /TaskSched/Icons/Period end.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/Period end.ico -------------------------------------------------------------------------------- /TaskSched/Icons/Properties.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/Properties.ico -------------------------------------------------------------------------------- /TaskSched/Icons/Schedule - disabled.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/Schedule - disabled.ico -------------------------------------------------------------------------------- /TaskSched/Icons/Schedule.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/Schedule.ico -------------------------------------------------------------------------------- /TaskSched/Icons/Timer.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/Timer.ico -------------------------------------------------------------------------------- /TaskSched/Icons/action.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/action.ico -------------------------------------------------------------------------------- /TaskSched/Icons/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/app.ico -------------------------------------------------------------------------------- /TaskSched/Icons/back.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/back.ico -------------------------------------------------------------------------------- /TaskSched/Icons/bullet.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/bullet.ico -------------------------------------------------------------------------------- /TaskSched/Icons/copy.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/copy.ico -------------------------------------------------------------------------------- /TaskSched/Icons/folder-open.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/folder-open.ico -------------------------------------------------------------------------------- /TaskSched/Icons/forward.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/forward.ico -------------------------------------------------------------------------------- /TaskSched/Icons/refresh.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/refresh.ico -------------------------------------------------------------------------------- /TaskSched/Icons/stop.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/stop.ico -------------------------------------------------------------------------------- /TaskSched/Icons/up.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/Icons/up.ico -------------------------------------------------------------------------------- /TaskSched/MainFrame.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "Resource.h" 3 | #include "MainFrame.h" 4 | #include "SecurityHelper.h" 5 | #include "AboutDlg.h" 6 | #include "IconHelper.h" 7 | #include "ComHelper.h" 8 | #include "SortHelper.h" 9 | 10 | BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) { 11 | if (CFrameWindowImpl::PreTranslateMessage(pMsg)) 12 | return TRUE; 13 | 14 | return FALSE; 15 | } 16 | 17 | BOOL CMainFrame::OnIdle() { 18 | UIUpdateToolBar(); 19 | return 0; 20 | } 21 | 22 | CString CMainFrame::GetColumnText(HWND h, int row, int col) const { 23 | if (h == m_Details) 24 | return GetDetailsColumnText(h, row, col); 25 | auto& item = m_Items[row]; 26 | switch (static_cast(GetColumnManager(h)->GetColumnTag(col))) { 27 | case ColumnType::Name: return item.Name; 28 | case ColumnType::Path: return item.Path; 29 | case ColumnType::Triggers: return TaskHelper::GetTaskTriggers(item.spTask); 30 | case ColumnType::Status: return TaskHelper::TaskStateToString(GetTaskState(item)); 31 | case ColumnType::InstanceGuid: 32 | { 33 | CComBSTR guid; 34 | item.spRunningTask->get_InstanceGuid(&guid); 35 | return CString(guid); 36 | } 37 | case ColumnType::RunningPid: 38 | { 39 | DWORD pid; 40 | item.spRunningTask->get_EnginePID(&pid); 41 | CString text; 42 | text.Format(L"%u (%s)", pid, (PCWSTR)TaskHelper::GetProcessName(pid)); 43 | return text; 44 | } 45 | case ColumnType::LastRun: 46 | { 47 | DATE date; 48 | item.spTask->get_LastRunTime(&date); 49 | 50 | if (date == 0) 51 | return L""; 52 | 53 | CComVariant v(date, VT_DATE); 54 | v.ChangeType(VT_BSTR); 55 | return CString(v.bstrVal); 56 | } 57 | case ColumnType::NextRun: 58 | { 59 | if (item.NextRun == 0) 60 | item.spTask->get_NextRunTime(&item.NextRun); 61 | 62 | if (item.NextRun == 0) 63 | return L""; 64 | 65 | CComVariant v(item.NextRun, VT_DATE); 66 | v.ChangeType(VT_BSTR); 67 | return CString(v.bstrVal); 68 | } 69 | case ColumnType::RunResults: 70 | { 71 | LONG result; 72 | item.spTask->get_LastTaskResult(&result); 73 | auto msg = TaskHelper::FormatMessage(result); 74 | msg.Format(L"%s (0x%X)", (PCWSTR)msg, result); 75 | return msg; 76 | } 77 | case ColumnType::Created: return GetTaskCreateDate(item); 78 | case ColumnType::Author: return GetTaskAuthor(item); 79 | case ColumnType::CurrentAction: 80 | { 81 | CComBSTR action; 82 | item.spRunningTask->get_CurrentAction(&action); 83 | return CString(action); 84 | } 85 | } 86 | return L""; 87 | } 88 | 89 | CString CMainFrame::GetDetailsColumnText(HWND, int row, int col) const { 90 | return col == 0 ? m_ItemDetails[row].Name : m_ItemDetails[row].Details; 91 | } 92 | 93 | int CMainFrame::GetRowImage(HWND h, int row, int col) const { 94 | if (h == m_Details) 95 | return static_cast(m_ItemDetails[row].Image); 96 | 97 | auto& item = m_Items[row]; 98 | switch (GetTaskState(item)) { 99 | case TASK_STATE_DISABLED: return 1; 100 | case TASK_STATE_RUNNING: return 2; 101 | } 102 | return 0; 103 | } 104 | 105 | void CMainFrame::DoSort(const SortInfo* si) { 106 | if (si == nullptr || si->SortColumn < 0) 107 | return; 108 | 109 | if (si->hWnd == m_Details) 110 | return DoSortDetails(si); 111 | 112 | auto cm = GetColumnManager(m_List); 113 | auto asc = si->SortAscending; 114 | auto col = cm->GetColumnTag(si->SortColumn); 115 | auto compare = [&](auto& item1, auto& item2) { 116 | switch (col) { 117 | case ColumnType::Name: return SortHelper::Sort(item1.Name, item2.Name, asc); 118 | case ColumnType::Path: return SortHelper::Sort(item1.Path, item2.Path, asc); 119 | case ColumnType::Status: return SortHelper::Sort(GetTaskState(item1), GetTaskState(item2), asc); 120 | case ColumnType::RunningPid: 121 | { 122 | DWORD p1, p2; 123 | item1.spRunningTask->get_EnginePID(&p1); 124 | item2.spRunningTask->get_EnginePID(&p2); 125 | return SortHelper::Sort(p1, p2, asc); 126 | } 127 | case ColumnType::RunResults: 128 | { 129 | LONG r1, r2; 130 | item1.spTask->get_LastTaskResult(&r1); 131 | item1.spTask->get_LastTaskResult(&r2); 132 | return SortHelper::Sort(r1, r2, asc); 133 | } 134 | case ColumnType::Author: return SortHelper::Sort(GetTaskAuthor(item1), GetTaskAuthor(item2), asc); 135 | case ColumnType::Created: return SortHelper::Sort(GetTaskCreateDate(item1), GetTaskCreateDate(item2), asc); 136 | case ColumnType::Triggers: return SortHelper::Sort(TaskHelper::GetTaskTriggers(item1.spTask), TaskHelper::GetTaskTriggers(item2.spTask), asc); 137 | case ColumnType::LastRun: 138 | { 139 | DATE d1, d2; 140 | item1.spTask->get_LastRunTime(&d1); 141 | item2.spTask->get_LastRunTime(&d2); 142 | return SortHelper::Sort(d1, d2, asc); 143 | } 144 | case ColumnType::NextRun: 145 | { 146 | DATE d1 = item1.NextRun, d2 = item2.NextRun; 147 | if (d1 == 0) { 148 | item1.spTask->get_NextRunTime(&d1); 149 | item1.NextRun = d1; 150 | } 151 | if (d2 == 0) { 152 | item2.spTask->get_NextRunTime(&d2); 153 | item2.NextRun = d2; 154 | } 155 | return SortHelper::Sort(d1, d2, asc); 156 | } 157 | } 158 | return false; 159 | }; 160 | 161 | CWaitCursor wait(false); 162 | if (col == ColumnType::Triggers && m_Items.size() > 30) 163 | wait.Set(); 164 | std::sort(m_Items.begin(), m_Items.end(), compare); 165 | } 166 | 167 | void CMainFrame::DoSortDetails(const SortInfo* si) { 168 | std::sort(m_ItemDetails.begin(), m_ItemDetails.end(), [&](const auto& d1, const auto& d2) { 169 | switch (si->SortColumn) { 170 | case 0: return SortHelper::Sort(d1.Name, d2.Name, si->SortAscending); 171 | case 1: return SortHelper::Sort(d1.Details, d2.Details, si->SortAscending); 172 | } 173 | return false; 174 | }); 175 | } 176 | 177 | BOOL CMainFrame::OnRightClickList(HWND h, int row, int col, const POINT& pt) { 178 | CMenu menu; 179 | menu.LoadMenu(IDR_CONTEXT); 180 | 181 | return m_CmdBar.TrackPopupMenu(menu.GetSubMenu(h == m_List ? 0 : 2), 0, pt.x, pt.y); 182 | } 183 | 184 | LRESULT CMainFrame::OnCreate(UINT, WPARAM, LPARAM, BOOL&) { 185 | auto hr = m_TaskSvc.Init(); 186 | if (FAILED(hr)) { 187 | AtlMessageBox(m_hWnd, L"Failed to connect to task scheduler service.", IDS_APP_TITLE, MB_ICONERROR); 188 | return -1; 189 | } 190 | 191 | CMenuHandle menu = GetMenu(); 192 | if (SecurityHelper::IsRunningElevated()) { 193 | auto fileMenu = menu.GetSubMenu(0); 194 | fileMenu.DeleteMenu(0, MF_BYPOSITION); 195 | fileMenu.DeleteMenu(0, MF_BYPOSITION); 196 | CString text; 197 | GetWindowText(text); 198 | text += L" (Administrator)"; 199 | SetWindowText(text); 200 | } 201 | 202 | HWND hWndCmdBar = m_CmdBar.Create(m_hWnd, rcDefault, nullptr, ATL_SIMPLE_CMDBAR_PANE_STYLE); 203 | 204 | m_CmdBar.SetAlphaImages(true); 205 | m_CmdBar.AttachMenu(menu); 206 | InitCommandBar(); 207 | 208 | UIAddMenu(menu); 209 | SetMenu(nullptr); 210 | 211 | CToolBarCtrl tb; 212 | tb.Create(m_hWnd, nullptr, nullptr, ATL_SIMPLE_TOOLBAR_PANE_STYLE, 0, ATL_IDW_TOOLBAR); 213 | InitToolBar(tb, 24); 214 | UIAddToolBar(tb); 215 | 216 | CreateSimpleReBar(ATL_SIMPLE_REBAR_NOBORDER_STYLE); 217 | AddSimpleReBarBand(hWndCmdBar); 218 | AddSimpleReBarBand(tb, nullptr, TRUE); 219 | 220 | CReBarCtrl rb(m_hWndToolBar); 221 | rb.LockBands(true); 222 | 223 | CreateSimpleStatusBar(ATL_IDS_IDLEMESSAGE, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP | SBT_TOOLTIPS); 224 | m_StatusBar.SubclassWindow(m_hWndStatusBar); 225 | 226 | m_hWndClient = m_MainSplitter.Create(m_hWnd, rcDefault, nullptr, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE); 227 | 228 | m_Tree.Create(m_MainSplitter, rcDefault, nullptr, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | 229 | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_HASLINES | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS, 0); 230 | { 231 | CImageList images; 232 | images.Create(16, 16, ILC_COLOR32, 4, 4); 233 | UINT icons[] = { 234 | IDI_FOLDER, IDI_FOLDER_OPEN, IDR_MAINFRAME, IDI_PLAY 235 | }; 236 | for (auto icon : icons) 237 | images.AddIcon(AtlLoadIconImage(icon, 0, 16, 16)); 238 | m_Tree.SetImageList(images, TVSIL_NORMAL); 239 | } 240 | ::SetWindowTheme(m_Tree, L"Explorer", nullptr); 241 | 242 | m_ListSplitter.Create(m_MainSplitter, rcDefault, nullptr, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0); 243 | m_ListSplitter.SetSplitterPosPct(50); 244 | m_MainSplitter.SetSplitterPanes(m_Tree, m_ListSplitter); 245 | m_MainSplitter.SetSplitterPosPct(25); 246 | m_MainSplitter.UpdateSplitterLayout(); 247 | 248 | m_List.Create(m_ListSplitter, rcDefault, nullptr, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN 249 | | LVS_OWNERDATA | LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS, 0, TaskListId); 250 | m_List.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP); 251 | { 252 | CImageList images; 253 | images.Create(16, 16, ILC_COLOR32, 4, 4); 254 | UINT icons[] = { 255 | IDI_TASK, IDI_TASK_DISABLED, IDI_PLAY 256 | }; 257 | for (auto icon : icons) 258 | images.AddIcon(AtlLoadIconImage(icon, 0, 16, 16)); 259 | m_List.SetImageList(images, LVSIL_SMALL); 260 | } 261 | 262 | m_Details.Create(m_ListSplitter, rcDefault, nullptr, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN 263 | | LVS_OWNERDATA | LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS, 0, DetailsListId); 264 | m_Details.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP); 265 | { 266 | CImageList images; 267 | images.Create(16, 16, ILC_COLOR32, 8, 4); 268 | UINT icons[] = { 269 | IDI_GENERIC, IDI_YES, IDI_CANCEL, IDI_ACTION, IDI_TIMER 270 | }; 271 | for (auto icon : icons) 272 | images.AddIcon(AtlLoadIconImage(icon, 0, 16, 16)); 273 | m_Details.SetImageList(images, LVSIL_SMALL); 274 | } 275 | 276 | auto cm = GetColumnManager(m_Details); 277 | cm->AddColumn(L"Name", LVCFMT_LEFT, 150); 278 | cm->AddColumn(L"Details", LVCFMT_LEFT, 700); 279 | 280 | SwitchColumns(); 281 | 282 | m_ListSplitter.SetSplitterPanes(m_List, m_Details); 283 | 284 | CMessageLoop* pLoop = _Module.GetMessageLoop(); 285 | ATLASSERT(pLoop != NULL); 286 | pLoop->AddMessageFilter(this); 287 | pLoop->AddIdleHandler(this); 288 | 289 | UpdateLayout(); 290 | PostMessage(WM_BUILD_TREE); 291 | UpdateUI(); 292 | 293 | return 0; 294 | } 295 | 296 | LRESULT CMainFrame::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { 297 | // unregister message filtering and idle updates 298 | CMessageLoop* pLoop = _Module.GetMessageLoop(); 299 | ATLASSERT(pLoop != NULL); 300 | pLoop->RemoveMessageFilter(this); 301 | pLoop->RemoveIdleHandler(this); 302 | 303 | bHandled = FALSE; 304 | return 1; 305 | } 306 | 307 | LRESULT CMainFrame::OnExit(WORD, WORD, HWND, BOOL&) { 308 | PostMessage(WM_CLOSE); 309 | return 0; 310 | } 311 | 312 | LRESULT CMainFrame::OnAbout(WORD, WORD, HWND, BOOL&) { 313 | CAboutDlg().DoModal(); 314 | return 0; 315 | } 316 | 317 | LRESULT CMainFrame::OnBuildTree(UINT, WPARAM, LPARAM, BOOL&) { 318 | BuildTaskTree(); 319 | return 0; 320 | } 321 | 322 | LRESULT CMainFrame::OnTreeSelChanged(int, LPNMHDR, BOOL&) { 323 | RefreshList(); 324 | return 0; 325 | } 326 | 327 | void CMainFrame::RefreshList() { 328 | m_Items.clear(); 329 | m_List.SetItemCount(0); 330 | m_spCurrentFolder = nullptr; 331 | auto item = m_Tree.GetSelectedItem(); 332 | auto oldNodeType = m_CurrentNodeType; 333 | m_CurrentNodeType = static_cast(item.GetData()); 334 | UpdateDetails(); 335 | switch (static_cast(m_Tree.GetItemData(item))) { 336 | case NodeType::AllTasks: 337 | if (oldNodeType == NodeType::RunningTasks) 338 | SwitchColumns(); 339 | EnumAllTasks(); 340 | DoSort(GetSortInfo(m_List)); 341 | return; 342 | 343 | case NodeType::RunningTasks: 344 | SwitchColumns(); 345 | EnumRunningTasks(); 346 | DoSort(GetSortInfo(m_List)); 347 | return; 348 | } 349 | 350 | if (oldNodeType == NodeType::RunningTasks) 351 | SwitchColumns(); 352 | auto folderPath = GetFolderPath(item); 353 | if (!folderPath.IsEmpty()) { 354 | m_TaskSvc->GetFolder(CComBSTR(folderPath), &m_spCurrentFolder); 355 | ATLASSERT(m_spCurrentFolder); 356 | EnumTasks(); 357 | DoSort(GetSortInfo(m_List)); 358 | } 359 | return; 360 | } 361 | 362 | void CMainFrame::UpdateDetails() { 363 | int selected = m_List.GetSelectedIndex(); 364 | if (selected < 0) { 365 | m_Details.SetItemCount(0); 366 | } 367 | else { 368 | auto count = UpdateItemDetails(m_Items[selected]); 369 | m_Details.SetItemCountEx(count, LVSICF_NOSCROLL | LVSICF_NOINVALIDATEALL); 370 | m_Details.RedrawItems(m_Details.GetTopIndex(), m_Details.GetTopIndex() + m_Details.GetCountPerPage()); 371 | } 372 | } 373 | 374 | int CMainFrame::UpdateItemDetails(const TaskItem& item) { 375 | m_ItemDetails.clear(); 376 | m_ItemDetails.reserve(32); 377 | 378 | m_ItemDetails.push_back(DetailsItem{ L"Name", item.Name }); 379 | m_ItemDetails.push_back(DetailsItem{ L"Path", item.Path }); 380 | m_ItemDetails.push_back(DetailsItem{ L"State", TaskHelper::TaskStateToString(GetTaskState(item)) }); 381 | 382 | CString text; 383 | if (item.spRunningTask) { 384 | DWORD pid; 385 | item.spRunningTask->get_EnginePID(&pid); 386 | text.Format(L"PID: %u (0x%X) [%s]", pid, pid, (PCWSTR)TaskHelper::GetProcessName(pid)); 387 | m_ItemDetails.push_back(DetailsItem{ L"Process", text }); 388 | CComBSTR btext; 389 | item.spRunningTask->get_InstanceGuid(&btext); 390 | m_ItemDetails.push_back(DetailsItem{ L"Instance", CString(btext) }); 391 | item.spRunningTask->get_CurrentAction(&btext); 392 | m_ItemDetails.push_back(DetailsItem{ L"Current Action", CString(btext) }); 393 | } 394 | else { 395 | // get triggers 396 | CComPtr spDef; 397 | item.spTask->get_Definition(&spDef); 398 | CComPtr spColl; 399 | spDef->get_Triggers(&spColl); 400 | long count; 401 | spColl->get_Count(&count); 402 | if (count > 0) { 403 | int t = 0; 404 | ComHelper::DoForeachNoVariant(spColl, [&](ITrigger* trigger) { 405 | t++; 406 | VARIANT_BOOL enabled; 407 | trigger->get_Enabled(&enabled); 408 | TASK_TRIGGER_TYPE2 triggerType; 409 | trigger->get_Type(&triggerType); 410 | CComBSTR id; 411 | trigger->get_Id(&id); 412 | CComPtr spRepeat; 413 | trigger->get_Repetition(&spRepeat); 414 | auto repeat = TaskHelper::GetRepeatPattern(spRepeat); 415 | 416 | DetailsItem di; 417 | text = L"Trigger"; 418 | if (count > 1) 419 | di.Name.Format(L"%s %d", (PCWSTR)text, t); 420 | else 421 | di.Name = text; 422 | text = TaskHelper::TriggerTypeToString(triggerType); 423 | di.Name += L": " + text; 424 | text.Empty(); 425 | if (!enabled) 426 | text += L"(Disabled) "; 427 | 428 | CComBSTR boundary; 429 | trigger->get_StartBoundary(&boundary); 430 | if (boundary.Length()) { 431 | text += L"Start: " + TaskHelper::CreateDateTimeToString(CString(boundary)) + L" "; 432 | } 433 | trigger->get_EndBoundary(&boundary); 434 | if (boundary.Length()) { 435 | text += L"End: " + TaskHelper::CreateDateTimeToString(CString(boundary)) + L" "; 436 | } 437 | trigger->get_ExecutionTimeLimit(&boundary); 438 | if (boundary.Length()) { 439 | text += L"Time Limit: " + CString(boundary) + L" "; 440 | } 441 | 442 | di.Details = text + repeat; 443 | di.Image = IconIndex::Trigger; 444 | 445 | if(CComQIPtr spLogon(trigger); spLogon) { 446 | spLogon->get_Delay(&boundary); 447 | if (boundary.Length()) { 448 | text.Format(L" Delay: %s", boundary.m_str); 449 | di.Details += text; 450 | } 451 | spLogon->get_UserId(&boundary); 452 | if (boundary.Length()) { 453 | text.Format(L" User: %s", boundary.m_str); 454 | di.Details += text; 455 | } 456 | } 457 | if(CComQIPtr spSession(trigger); spSession) { 458 | spSession->get_Delay(&boundary); 459 | if (boundary.Length()) { 460 | text.Format(L" Delay: %s", boundary.m_str); 461 | di.Details += text; 462 | } 463 | spSession->get_UserId(&boundary); 464 | if (boundary.Length()) { 465 | text.Format(L" User: %s", boundary.m_str); 466 | di.Details += text; 467 | } 468 | TASK_SESSION_STATE_CHANGE_TYPE type; 469 | spSession->get_StateChange(&type); 470 | di.Details += CString(L" State Change: ") + TaskHelper::StateChangeToString(type); 471 | } 472 | m_ItemDetails.push_back(std::move(di)); 473 | }); 474 | } 475 | 476 | CComPtr spActions; 477 | spDef->get_Actions(&spActions); 478 | CComBSTR context; 479 | spActions->get_Context(&context); 480 | if (context.Length()) { 481 | m_ItemDetails.push_back(DetailsItem{ L"Actions Context", CString(context) }); 482 | } 483 | spActions->get_Count(&count); 484 | if (count > 0) { 485 | int index = 0; 486 | ComHelper::DoForeachNoVariant(spActions, [&](IAction* action) { 487 | index++; 488 | TASK_ACTION_TYPE type; 489 | action->get_Type(&type); 490 | DetailsItem di; 491 | text = L"Action"; 492 | if (count > 1) 493 | di.Name.Format(L"%s %d", text, index); 494 | di.Name += text + L": " + TaskHelper::ActionTypeToString(type); 495 | 496 | CComQIPtr spExecAction(action); 497 | if (spExecAction) { 498 | text.Empty(); 499 | CComBSTR path; 500 | spExecAction->get_Path(&path); 501 | text = L"Path: " + CString(path); 502 | spExecAction->get_Arguments(&path); 503 | if (path.Length()) 504 | text += L" Arguments: " + CString(path); 505 | spExecAction->get_WorkingDirectory(&path); 506 | if (path.Length()) 507 | text += L" Working Directory: " + CString(path); 508 | di.Details = text; 509 | } 510 | CComQIPtr spShowAction(action); 511 | if (spShowAction) { 512 | CComBSTR value; 513 | spShowAction->get_Title(&value); 514 | text = L"Title: " + CString(value); 515 | spShowAction->get_MessageBody(&value); 516 | text = L"Message: " + CString(value); 517 | di.Details = text; 518 | } 519 | CComQIPtr spHandler(action); 520 | if (spHandler) { 521 | CComBSTR value; 522 | spHandler->get_ClassId(&value); 523 | text = L"CLSID: " + CString(value); 524 | spHandler->get_Data(&value); 525 | if (value.Length()) 526 | text += L" Data: " + CString(value); 527 | di.Details = text; 528 | } 529 | di.Image = IconIndex::Action; 530 | m_ItemDetails.push_back(std::move(di)); 531 | }); 532 | } 533 | 534 | CComBSTR value; 535 | spDef->get_Data(&value); 536 | if (value.Length()) { 537 | m_ItemDetails.push_back(DetailsItem{ L"User Data", CString(value) }); 538 | } 539 | CComPtr spSettings; 540 | spDef->get_Settings(&spSettings); 541 | VARIANT_BOOL b; 542 | spSettings->get_Hidden(&b); 543 | m_ItemDetails.push_back(DetailsItem{ L"Visible", b ? L"False" : L"True", b ? IconIndex::No : IconIndex::Yes }); 544 | spSettings->get_AllowDemandStart(&b); 545 | m_ItemDetails.push_back(DetailsItem{ L"Allow Demand Start", b ? L"True" : L"False" , b ? IconIndex::Yes : IconIndex::No }); 546 | spSettings->get_AllowHardTerminate(&b); 547 | m_ItemDetails.push_back(DetailsItem{ L"Allow Hard Terminate", b ? L"True" : L"False" , b ? IconIndex::Yes : IconIndex::No }); 548 | spSettings->get_DisallowStartIfOnBatteries(&b); 549 | m_ItemDetails.push_back(DetailsItem{ L"Allow Start on Battery", b ? L"False" : L"True" , b ? IconIndex::No : IconIndex::Yes }); 550 | int priority; 551 | spSettings->get_Priority(&priority); 552 | text.Format(L"%d", priority); 553 | m_ItemDetails.push_back(DetailsItem{ L"Priority", text }); 554 | spSettings->get_ExecutionTimeLimit(&value); 555 | if (value.Length()) 556 | m_ItemDetails.push_back(DetailsItem{ L"Execution Time Limit", CString(value) }); 557 | } 558 | DoSort(GetSortInfo(m_Details)); 559 | return static_cast(m_ItemDetails.size()); 560 | } 561 | 562 | LRESULT CMainFrame::OnRunAsAdmin(WORD, WORD, HWND, BOOL&) { 563 | if (SecurityHelper::RunElevated()) 564 | PostMessage(WM_CLOSE); 565 | 566 | return 0; 567 | } 568 | 569 | LRESULT CMainFrame::OnEnableDisableTask(WORD, WORD, HWND, BOOL&) { 570 | auto index = m_List.GetSelectedIndex(); 571 | ATLASSERT(index >= 0); 572 | 573 | auto& item = m_Items[index]; 574 | ATLASSERT(item.spTask); 575 | VARIANT_BOOL enabled; 576 | item.spTask->get_Enabled(&enabled); 577 | auto hr = item.spTask->put_Enabled(enabled ? VARIANT_FALSE : VARIANT_TRUE); 578 | if (FAILED(hr)) { 579 | AtlMessageBox(m_hWnd, (PCWSTR)TaskHelper::FormatMessage(hr), IDS_APP_TITLE, MB_ICONERROR); 580 | } 581 | else { 582 | m_List.RedrawItems(index, index); 583 | UpdateUI(); 584 | } 585 | return 0; 586 | } 587 | 588 | LRESULT CMainFrame::OnListItemChanged(int, LPNMHDR, BOOL&) { 589 | int selected = m_List.GetSelectedIndex(); 590 | if (selected != m_CurrentSelectedItem) { 591 | m_CurrentSelectedItem = selected; 592 | UpdateDetails(); 593 | UpdateUI(); 594 | } 595 | return 0; 596 | } 597 | 598 | LRESULT CMainFrame::OnViewRefresh(WORD, WORD, HWND, BOOL&) { 599 | int selected = m_List.GetSelectedIndex(); 600 | RefreshList(); 601 | m_List.SetFocus(); 602 | if (selected >= 0) { 603 | m_List.SetItemState(selected, LVIS_SELECTED, LVIS_SELECTED); 604 | } 605 | return 0; 606 | } 607 | 608 | LRESULT CMainFrame::OnRunTask(WORD, WORD, HWND, BOOL&) { 609 | int selected = m_List.GetSelectedIndex(); 610 | ATLASSERT(selected >= 0); 611 | auto& item = m_Items[selected]; 612 | ATLASSERT(item.spTask); 613 | CComPtr spRunning; 614 | auto hr = item.spTask->Run(CComVariant(), &spRunning); 615 | if (FAILED(hr)) { 616 | AtlMessageBox(m_hWnd, (PCWSTR)TaskHelper::FormatMessage(hr), IDS_APP_TITLE, MB_ICONERROR); 617 | } 618 | else { 619 | m_List.RedrawItems(selected, selected); 620 | } 621 | return 0; 622 | } 623 | 624 | LRESULT CMainFrame::OnStopTask(WORD, WORD, HWND, BOOL&) { 625 | int selected = m_List.GetSelectedIndex(); 626 | ATLASSERT(selected >= 0); 627 | auto& item = m_Items[selected]; 628 | HRESULT hr; 629 | if (item.spTask) { 630 | TASK_STATE state; 631 | item.spTask->get_State(&state); 632 | if (state != TASK_STATE_RUNNING) { 633 | AtlMessageBox(m_hWnd, L"Task is not running.", IDS_APP_TITLE, MB_ICONWARNING); 634 | return 0; 635 | } 636 | hr = item.spTask->Stop(0); 637 | } 638 | else { 639 | hr = item.spRunningTask->Stop(); 640 | } 641 | if (FAILED(hr)) { 642 | AtlMessageBox(m_hWnd, (PCWSTR)TaskHelper::FormatMessage(hr), IDS_APP_TITLE, MB_ICONERROR); 643 | } 644 | else { 645 | m_List.RedrawItems(selected, selected); 646 | } 647 | return 0; 648 | } 649 | 650 | LRESULT CMainFrame::OnDeleteTask(WORD, WORD, HWND, BOOL&) { 651 | int selected = m_List.GetSelectedIndex(); 652 | ATLASSERT(selected >= 0); 653 | auto& item = m_Items[selected]; 654 | ATLASSERT(item.spTask); 655 | auto hr = m_spCurrentFolder->DeleteTask(CComBSTR(item.Name), 0); 656 | if (FAILED(hr)) { 657 | AtlMessageBox(m_hWnd, (PCWSTR)TaskHelper::FormatMessage(hr), IDS_APP_TITLE, MB_ICONERROR); 658 | } 659 | else { 660 | m_Items.erase(m_Items.begin() + selected); 661 | m_List.SetItemCountEx(static_cast(m_Items.size()), LVSICF_NOSCROLL); 662 | m_List.RedrawItems(selected, selected); 663 | } 664 | return 0; 665 | } 666 | 667 | void CMainFrame::InitCommandBar() { 668 | struct { 669 | UINT id, icon; 670 | HICON hIcon = nullptr; 671 | } cmds[] = { 672 | { ID_FILE_RUNASADMIN, 0, IconHelper::GetShieldIcon() }, 673 | { ID_EDIT_COPY, IDI_COPY }, 674 | { ID_TASK_RUN, IDI_PLAY }, 675 | { ID_TASK_STOP, IDI_STOP }, 676 | { ID_VIEW_REFRESH, IDI_REFRESH }, 677 | { ID_TASK_DELETE, IDI_DELETE }, 678 | }; 679 | for (auto& cmd : cmds) { 680 | HICON hIcon = cmd.hIcon; 681 | if (!hIcon) { 682 | hIcon = AtlLoadIconImage(cmd.icon, 0, 16, 16); 683 | ATLASSERT(hIcon); 684 | } 685 | m_CmdBar.AddIcon(cmd.icon ? hIcon : cmd.hIcon, cmd.id); 686 | } 687 | } 688 | 689 | void CMainFrame::InitToolBar(CToolBarCtrl& tb, int size) { 690 | CImageList tbImages; 691 | tbImages.Create(size, size, ILC_COLOR32, 8, 4); 692 | tb.SetImageList(tbImages); 693 | 694 | const struct { 695 | UINT id; 696 | int image; 697 | BYTE style = BTNS_BUTTON; 698 | PCWSTR text = nullptr; 699 | } buttons[] = { 700 | { ID_VIEW_REFRESH, IDI_REFRESH }, 701 | { 0 }, 702 | { ID_EDIT_COPY, IDI_COPY }, 703 | { ID_EDIT_FIND, IDI_FIND }, 704 | { 0 }, 705 | { ID_TASK_RUN, IDI_PLAY }, 706 | }; 707 | for (auto& b : buttons) { 708 | if (b.id == 0) 709 | tb.AddSeparator(0); 710 | else { 711 | auto hIcon = AtlLoadIconImage(b.image, 0, size, size); 712 | ATLASSERT(hIcon); 713 | int image = tbImages.AddIcon(hIcon); 714 | tb.AddButton(b.id, b.style, TBSTATE_ENABLED, image, b.text, 0); 715 | } 716 | } 717 | } 718 | 719 | HRESULT CMainFrame::BuildTaskTree() { 720 | m_Tree.SetRedraw(FALSE); 721 | m_Tree.DeleteAllItems(); 722 | 723 | auto root = m_Tree.InsertItem(L"Task Scheduler (Local)", 2, 2, TVI_ROOT, TVI_LAST); 724 | root.SetData(static_cast(NodeType::TaskSched)); 725 | auto running = m_Tree.InsertItem(L"Running Tasks", 3, 3, root, TVI_LAST); 726 | running.SetData(static_cast(NodeType::RunningTasks)); 727 | auto all = m_Tree.InsertItem(L"All Tasks", 2, 2, root, TVI_LAST); 728 | all.SetData(static_cast(NodeType::AllTasks)); 729 | 730 | CComPtr spFolder; 731 | auto hr = m_TaskSvc->GetFolder(CComBSTR(L"\\"), &spFolder); 732 | if (spFolder) 733 | hr = BuildTaskTree(spFolder, root); 734 | root.Expand(TVE_EXPAND); 735 | m_Tree.SetRedraw(TRUE); 736 | m_Tree.SelectItem(root); 737 | 738 | return hr; 739 | } 740 | 741 | HRESULT CMainFrame::BuildTaskTree(ITaskFolder* folder, CTreeItem root) { 742 | CComPtr spColl; 743 | auto hr = folder->GetFolders(0, &spColl); 744 | if (FAILED(hr)) 745 | return hr; 746 | 747 | ComHelper::DoForeach(spColl, [&](auto subfolder) { 748 | CComBSTR name; 749 | subfolder->get_Name(&name); 750 | auto item = m_Tree.InsertItem(name, 0, 1, root, TVI_LAST); 751 | item.SetData(static_cast(NodeType::Folder)); 752 | BuildTaskTree(subfolder, item); 753 | }); 754 | 755 | return S_OK; 756 | } 757 | 758 | CString CMainFrame::GetFolderPath(HTREEITEM hItem) const { 759 | CString path; 760 | while (hItem && m_Tree.GetItemData(hItem) == static_cast(NodeType::Folder)) { 761 | CString name; 762 | m_Tree.GetItemText(hItem, name); 763 | path = name + L"\\" + path; 764 | hItem = m_Tree.GetParentItem(hItem); 765 | } 766 | return L"\\" + path.TrimRight(L"\\"); 767 | } 768 | 769 | TASK_STATE CMainFrame::GetTaskState(const TaskItem& item) const { 770 | TASK_STATE state; 771 | item.spTask ? item.spTask->get_State(&state) : item.spRunningTask->get_State(&state); 772 | return state; 773 | } 774 | 775 | CString CMainFrame::GetTaskAuthor(const TaskItem& item) const { 776 | auto spInfo = TaskHelper::GetRegistrationInfo(item.spTask); 777 | CComBSTR author; 778 | spInfo->get_Author(&author); 779 | return CString(author); 780 | } 781 | 782 | CString CMainFrame::GetTaskCreateDate(const TaskItem& item) const { 783 | auto spInfo = TaskHelper::GetRegistrationInfo(item.spTask); 784 | CComBSTR date; 785 | spInfo->get_Date(&date); 786 | return date == 0 ? L"" : (PCWSTR)TaskHelper::CreateDateTimeToString(date); 787 | } 788 | 789 | void CMainFrame::EnumTasks() { 790 | if (m_spCurrentFolder == nullptr) 791 | return; 792 | auto path = GetFolderPath(m_Tree.GetSelectedItem()); 793 | path.TrimRight(L"\\"); 794 | CComPtr spColl; 795 | m_spCurrentFolder->GetTasks(TASK_ENUM_HIDDEN, &spColl); 796 | ComHelper::DoForeach(spColl, [&](auto task) { 797 | TaskItem item; 798 | item.spTask = task; 799 | CComBSTR name; 800 | task->get_Name(&name); 801 | item.Name = name; 802 | task->get_Path(&name); 803 | item.Path = name; 804 | m_Items.push_back(item); 805 | }); 806 | m_List.SetItemCountEx(static_cast(m_Items.size()), LVSICF_NOSCROLL); 807 | } 808 | 809 | void CMainFrame::EnumAllTasks() { 810 | CWaitCursor wait; 811 | CComPtr spFolder; 812 | m_TaskSvc->GetFolder(CComBSTR(L"\\"), &spFolder); 813 | m_Items.clear(); 814 | AddTasks(spFolder); 815 | m_List.SetItemCountEx(static_cast(m_Items.size()), LVSICF_NOSCROLL); 816 | } 817 | 818 | void CMainFrame::EnumRunningTasks() { 819 | m_Items.clear(); 820 | CComPtr spColl; 821 | m_TaskSvc->GetRunningTasks(TASK_ENUM_HIDDEN, &spColl); 822 | ComHelper::DoForeach(spColl, [&](auto task) { 823 | CComBSTR name; 824 | task->get_Name(&name); 825 | TaskItem item; 826 | item.Name = name; 827 | task->get_Path(&name); 828 | item.Path = name; 829 | item.spRunningTask = task; 830 | m_Items.push_back(item); 831 | }); 832 | m_List.SetItemCountEx(static_cast(m_Items.size()), LVSICF_NOSCROLL); 833 | } 834 | 835 | void CMainFrame::AddTasks(ITaskFolder* folder) { 836 | CComPtr spColl; 837 | folder->GetTasks(TASK_ENUM_HIDDEN, &spColl); 838 | ComHelper::DoForeach(spColl, [&](auto task) { 839 | TaskItem item; 840 | item.spTask = task; 841 | CComBSTR name; 842 | task->get_Name(&name); 843 | item.Name = name; 844 | task->get_Path(&name); 845 | item.Path = name; 846 | m_Items.push_back(item); 847 | }); 848 | 849 | CComPtr spFolderColl; 850 | folder->GetFolders(0, &spFolderColl); 851 | ComHelper::DoForeach(spFolderColl, [&](auto p) { 852 | AddTasks(p); 853 | }); 854 | } 855 | 856 | void CMainFrame::SwitchColumns() { 857 | auto cm = GetColumnManager(m_List); 858 | if (m_CurrentNodeType == NodeType::RunningTasks) { 859 | m_TasksColumns = SaveState(m_List); 860 | } 861 | else { 862 | m_RunningTasksColumns = SaveState(m_List); 863 | } 864 | cm->Clear(); 865 | ClearSort(m_List); 866 | if (m_CurrentNodeType == NodeType::RunningTasks) { 867 | cm->AddColumn(L"Name", LVCFMT_LEFT, 250, ColumnType::Name); 868 | cm->AddColumn(L"Status", LVCFMT_LEFT, 80, ColumnType::Status); 869 | cm->AddColumn(L"Process", LVCFMT_LEFT, 190, ColumnType::RunningPid); 870 | cm->AddColumn(L"Instance", LVCFMT_LEFT, 160, ColumnType::InstanceGuid); 871 | cm->AddColumn(L"Current Action", LVCFMT_LEFT, 240, ColumnType::CurrentAction); 872 | cm->AddColumn(L"Path", LVCFMT_LEFT, 350, ColumnType::Path); 873 | cm->UpdateColumns(); 874 | LoadState(m_List, m_RunningTasksColumns); 875 | } 876 | else { 877 | cm->AddColumn(L"Name", LVCFMT_LEFT, 250, ColumnType::Name); 878 | cm->AddColumn(L"Status", LVCFMT_LEFT, 80, ColumnType::Status); 879 | cm->AddColumn(L"Triggers", LVCFMT_LEFT, 150, ColumnType::Triggers); 880 | cm->AddColumn(L"Created", LVCFMT_LEFT, 120, ColumnType::Created); 881 | cm->AddColumn(L"Next Run", LVCFMT_RIGHT, 150, ColumnType::NextRun); 882 | cm->AddColumn(L"Last Run", LVCFMT_RIGHT, 150, ColumnType::LastRun); 883 | cm->AddColumn(L"Last Result", LVCFMT_LEFT, 150, ColumnType::RunResults); 884 | cm->AddColumn(L"Author", LVCFMT_LEFT, 150, ColumnType::Author); 885 | cm->AddColumn(L"Path", LVCFMT_LEFT, 350, ColumnType::Path); 886 | cm->UpdateColumns(); 887 | LoadState(m_List, m_TasksColumns); 888 | } 889 | } 890 | 891 | void CMainFrame::UpdateUI() { 892 | bool listFocus = ::GetFocus() == m_List; 893 | auto selected = m_List.GetSelectedIndex(); 894 | auto item = selected < 0 ? nullptr : &m_Items[selected]; 895 | 896 | UIEnable(ID_TASK_ENABLE, item && item->spTask); 897 | TASK_STATE state = TASK_STATE_UNKNOWN; 898 | if (item && item->spTask) { 899 | VARIANT_BOOL enabled; 900 | item->spTask->get_Enabled(&enabled); 901 | item->spTask->get_State(&state); 902 | UISetText(ID_TASK_ENABLE, enabled ? L"&Disable" : L"&Enable"); 903 | } 904 | UIEnable(ID_TASK_RUN, item && state != TASK_STATE_RUNNING && item->spRunningTask == nullptr); 905 | UIEnable(ID_TASK_EXPORT, item && item->spTask); 906 | UIEnable(ID_TASK_DELETE, selected >= 0); 907 | UIEnable(ID_TASK_STOP, item && (item->spRunningTask || state == TASK_STATE_RUNNING)); 908 | } 909 | -------------------------------------------------------------------------------- /TaskSched/MainFrame.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "TaskHelper.h" 4 | #include 5 | #include 6 | 7 | class CMainFrame : 8 | public CFrameWindowImpl, 9 | public CAutoUpdateUI, 10 | public CVirtualListView, 11 | public CMessageFilter, 12 | public CIdleHandler { 13 | public: 14 | DECLARE_FRAME_WND_CLASS(nullptr, IDR_MAINFRAME) 15 | 16 | const UINT WM_BUILD_TREE = WM_APP + 11; 17 | 18 | virtual BOOL PreTranslateMessage(MSG* pMsg); 19 | virtual BOOL OnIdle(); 20 | 21 | CString GetColumnText(HWND, int row, int col) const; 22 | CString GetDetailsColumnText(HWND, int row, int col) const; 23 | 24 | int GetRowImage(HWND, int row, int col) const; 25 | void DoSort(const SortInfo* si); 26 | void DoSortDetails(const SortInfo* si); 27 | BOOL OnRightClickList(HWND, int row, int col, const POINT&); 28 | 29 | enum { 30 | TaskListId = 129, 31 | DetailsListId 32 | }; 33 | 34 | enum class IconIndex { 35 | Generic, Yes, No, Action, Trigger, 36 | }; 37 | struct DetailsItem { 38 | CString Name; 39 | CString Details; 40 | IconIndex Image{ IconIndex::Generic }; 41 | }; 42 | 43 | BEGIN_MSG_MAP(CMainFrame) 44 | NOTIFY_CODE_HANDLER(TVN_SELCHANGED, OnTreeSelChanged) 45 | NOTIFY_HANDLER(TaskListId, LVN_ITEMCHANGED, OnListItemChanged) 46 | MESSAGE_HANDLER(WM_CREATE, OnCreate) 47 | MESSAGE_HANDLER(WM_DESTROY, OnDestroy) 48 | MESSAGE_HANDLER(WM_BUILD_TREE, OnBuildTree) 49 | COMMAND_ID_HANDLER(ID_FILE_RUNASADMIN, OnRunAsAdmin) 50 | COMMAND_ID_HANDLER(ID_TASK_ENABLE, OnEnableDisableTask) 51 | COMMAND_ID_HANDLER(ID_TASK_RUN, OnRunTask) 52 | COMMAND_ID_HANDLER(ID_TASK_STOP, OnStopTask) 53 | COMMAND_ID_HANDLER(ID_TASK_DELETE, OnDeleteTask) 54 | COMMAND_ID_HANDLER(IDM_EXIT, OnExit) 55 | COMMAND_ID_HANDLER(ID_VIEW_REFRESH, OnViewRefresh) 56 | COMMAND_ID_HANDLER(IDM_ABOUT, OnAbout) 57 | CHAIN_MSG_MAP(CAutoUpdateUI) 58 | CHAIN_MSG_MAP(CVirtualListView) 59 | CHAIN_MSG_MAP(CFrameWindowImpl) 60 | REFLECT_NOTIFICATIONS_EX() 61 | END_MSG_MAP() 62 | 63 | // Handler prototypes (uncomment arguments if needed): 64 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 65 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 66 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) 67 | 68 | private: 69 | enum class ColumnType { 70 | Name, Status, Triggers, Created, Path, 71 | Author, NextRun, LastRun, RunResults, 72 | RunningPid, InstanceGuid, CurrentAction 73 | }; 74 | enum class NodeType { 75 | None, 76 | Folder, TaskSched, RunningTasks, AllTasks 77 | }; 78 | struct TaskItem { 79 | CString Name; 80 | CString Path; 81 | mutable DATE NextRun{ 0 }; 82 | CComPtr spTask; 83 | CComPtr spRunningTask; 84 | }; 85 | 86 | LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 87 | LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 88 | LRESULT OnExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 89 | LRESULT OnAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 90 | LRESULT OnBuildTree(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 91 | LRESULT OnTreeSelChanged(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/); 92 | LRESULT OnRunAsAdmin(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 93 | LRESULT OnEnableDisableTask(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 94 | LRESULT OnListItemChanged(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/); 95 | LRESULT OnViewRefresh(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 96 | LRESULT OnViewRefreshAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 97 | LRESULT OnRunTask(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 98 | LRESULT OnStopTask(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 99 | LRESULT OnDeleteTask(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 100 | 101 | void InitCommandBar(); 102 | void InitToolBar(CToolBarCtrl& tb, int size = 24); 103 | HRESULT BuildTaskTree(); 104 | HRESULT BuildTaskTree(ITaskFolder* folder, CTreeItem root); 105 | CString GetFolderPath(HTREEITEM hItem) const; 106 | TASK_STATE GetTaskState(const TaskItem& item) const; 107 | CString GetTaskAuthor(const TaskItem& item) const; 108 | CString GetTaskCreateDate(const TaskItem& item) const; 109 | void RefreshList(); 110 | void UpdateDetails(); 111 | int UpdateItemDetails(const TaskItem& item); 112 | 113 | void EnumTasks(); 114 | void EnumAllTasks(); 115 | void EnumRunningTasks(); 116 | void AddTasks(ITaskFolder* folder); 117 | void SwitchColumns(); 118 | void UpdateUI(); 119 | 120 | CCommandBarCtrl m_CmdBar; 121 | CCustomSplitterWindow m_MainSplitter; 122 | CCustomHorSplitterWindow m_ListSplitter; 123 | CMultiPaneStatusBarCtrl m_StatusBar; 124 | CListViewCtrl m_List; 125 | CTreeViewCtrlEx m_Tree; 126 | CListViewCtrl m_Details; 127 | TaskSchedSvc m_TaskSvc; 128 | std::vector m_Items; 129 | std::vector m_ItemDetails; 130 | CComPtr m_spCurrentFolder; 131 | NodeType m_CurrentNodeType{ NodeType::None }; 132 | ColumnsState m_TasksColumns, m_RunningTasksColumns; 133 | int m_CurrentSelectedItem{ -1 }; 134 | }; 135 | -------------------------------------------------------------------------------- /TaskSched/SecurityHelper.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "SecurityHelper.h" 3 | 4 | bool SecurityHelper::IsRunningElevated() { 5 | static bool runningElevated = false; 6 | static bool runningElevatedCheck = false; 7 | if (runningElevatedCheck) 8 | return runningElevated; 9 | 10 | runningElevatedCheck = true; 11 | HANDLE hToken; 12 | if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &hToken)) 13 | return false; 14 | 15 | TOKEN_ELEVATION te; 16 | DWORD len; 17 | if (::GetTokenInformation(hToken, TokenElevation, &te, sizeof(te), &len)) { 18 | runningElevated = te.TokenIsElevated ? true : false; 19 | } 20 | ::CloseHandle(hToken); 21 | return runningElevated; 22 | } 23 | 24 | bool SecurityHelper::RunElevated() { 25 | WCHAR path[MAX_PATH]; 26 | ::GetModuleFileName(nullptr, path, _countof(path)); 27 | return (INT_PTR)::ShellExecute(nullptr, L"runas", path, nullptr, nullptr, SW_SHOWDEFAULT) > 31; 28 | } 29 | 30 | bool SecurityHelper::EnablePrivilege(PCWSTR privName, bool enable) { 31 | HANDLE hToken; 32 | if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken)) 33 | return false; 34 | bool result = false; 35 | TOKEN_PRIVILEGES tp; 36 | tp.PrivilegeCount = 1; 37 | tp.Privileges[0].Attributes = enable ? SE_PRIVILEGE_ENABLED : 0; 38 | if (::LookupPrivilegeValue(nullptr, privName, 39 | &tp.Privileges[0].Luid)) { 40 | if (::AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(tp), 41 | nullptr, nullptr)) 42 | result = ::GetLastError() == ERROR_SUCCESS; 43 | } 44 | ::CloseHandle(hToken); 45 | return result; 46 | } 47 | -------------------------------------------------------------------------------- /TaskSched/SecurityHelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct SecurityHelper abstract final { 4 | static bool IsRunningElevated(); 5 | static bool RunElevated(); 6 | static bool EnablePrivilege(PCWSTR priv, bool enable = true); 7 | }; 8 | -------------------------------------------------------------------------------- /TaskSched/TaskGeneralPage.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "resource.h" 3 | #include "TaskGeneralPage.h" 4 | 5 | LRESULT CTaskGeneralPage::OnInitDialog(UINT, WPARAM, LPARAM, BOOL&) { 6 | InitDynamicLayout(false); 7 | return LRESULT(); 8 | } 9 | -------------------------------------------------------------------------------- /TaskSched/TaskGeneralPage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CTaskGeneralPage : 4 | public CDialogImpl, 5 | public CDynamicDialogLayout { 6 | public: 7 | enum { IDD = IDP_GENERAL }; 8 | 9 | BEGIN_MSG_MAP(CTaskGeneralPage); 10 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 11 | CHAIN_MSG_MAP(CDynamicDialogLayout) 12 | END_MSG_MAP() 13 | 14 | // Handler prototypes (uncomment arguments if needed): 15 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 16 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 17 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) 18 | 19 | private: 20 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 21 | 22 | }; 23 | -------------------------------------------------------------------------------- /TaskSched/TaskHelper.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "TaskHelper.h" 3 | #include "ComHelper.h" 4 | 5 | HRESULT TaskSchedSvc::Init(PCWSTR machineName, PCWSTR username, PCWSTR domain, PCWSTR password) { 6 | auto hr = _svc.CoCreateInstance(__uuidof(TaskScheduler)); 7 | if (FAILED(hr)) 8 | return hr; 9 | 10 | hr = _svc->Connect(CComVariant(machineName), CComVariant(username), CComVariant(domain), CComVariant(password)); 11 | if (FAILED(hr)) 12 | return hr; 13 | 14 | return S_OK; 15 | } 16 | 17 | PCWSTR TaskHelper::TaskStateToString(TASK_STATE state) { 18 | switch (state) { 19 | case TASK_STATE_DISABLED: return L"Disabled"; 20 | case TASK_STATE_RUNNING: return L"Running"; 21 | case TASK_STATE_QUEUED: return L"Queued"; 22 | case TASK_STATE_READY: return L"Ready"; 23 | } 24 | return L"(Unknown)"; 25 | } 26 | 27 | PCWSTR TaskHelper::TriggerTypeToString(TASK_TRIGGER_TYPE2 type) { 28 | switch (type) { 29 | case TASK_TRIGGER_EVENT: return L"Event"; 30 | case TASK_TRIGGER_TIME: return L"Time"; 31 | case TASK_TRIGGER_DAILY: return L"Daily"; 32 | case TASK_TRIGGER_WEEKLY: return L"Weekly"; 33 | case TASK_TRIGGER_MONTHLY: return L"Monthly"; 34 | case TASK_TRIGGER_MONTHLYDOW: return L"Monthly Day of Week"; 35 | case TASK_TRIGGER_IDLE: return L"Idle"; 36 | case TASK_TRIGGER_REGISTRATION: return L"Registration"; 37 | case TASK_TRIGGER_BOOT: return L"Boot"; 38 | case TASK_TRIGGER_LOGON: return L"Logon"; 39 | case TASK_TRIGGER_SESSION_STATE_CHANGE: return L"Session State Change"; 40 | case TASK_TRIGGER_CUSTOM_TRIGGER_01: return L"Custom"; 41 | } 42 | return L"(Unknown)"; 43 | } 44 | 45 | CString TaskHelper::GetProcessName(DWORD pid) { 46 | auto hProcess = ::OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid); 47 | if (!hProcess) 48 | return L""; 49 | 50 | WCHAR path[MAX_PATH * 2]; 51 | DWORD len = _countof(path); 52 | auto count = ::QueryFullProcessImageName(hProcess, 0, path, &len); 53 | ::CloseHandle(hProcess); 54 | if(count) { 55 | return wcsrchr(path, L'\\') + 1; 56 | } 57 | return L""; 58 | } 59 | 60 | CString TaskHelper::FormatMessage(DWORD error) { 61 | LPTSTR buffer; 62 | if (::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr, error, 0, (LPTSTR)&buffer, 0, nullptr)) { 63 | CString msg(buffer); 64 | ::LocalFree(buffer); 65 | return msg; 66 | } 67 | 68 | return L""; 69 | } 70 | 71 | CString TaskHelper::CreateDateTimeToString(PCWSTR dt) { 72 | auto dts = CString(dt); 73 | SYSTEMTIME st = { 0 }; 74 | st.wYear = _wtoi(dts.Left(4)); 75 | st.wMonth = _wtoi(dts.Mid(5, 2)); 76 | st.wDay = _wtoi(dts.Mid(8, 2)); 77 | st.wHour = _wtoi(dts.Mid(11, 2)); 78 | st.wMinute = _wtoi(dts.Mid(14, 2)); 79 | st.wSecond = _wtoi(dts.Mid(17, 2)); 80 | 81 | return CTime(st).Format(L"%x %X"); 82 | } 83 | 84 | CComPtr TaskHelper::GetRegistrationInfo(IRegisteredTask* task) { 85 | CComPtr spDef; 86 | task->get_Definition(&spDef); 87 | CComPtr spInfo; 88 | spDef->get_RegistrationInfo(&spInfo); 89 | return spInfo; 90 | } 91 | 92 | CString TaskHelper::GetTaskTriggers(IRegisteredTask* task) { 93 | CComPtr spDef; 94 | task->get_Definition(&spDef); 95 | CComPtr spColl; 96 | spDef->get_Triggers(&spColl); 97 | CString triggers; 98 | int count = 0; 99 | ComHelper::DoForeachNoVariant(spColl, [&](auto trigger) { 100 | TASK_TRIGGER_TYPE2 type; 101 | trigger->get_Type(&type); 102 | triggers += TriggerTypeToString(type); 103 | triggers += L", "; 104 | count++; 105 | }); 106 | if (count > 0) { 107 | CString temp; 108 | temp.Format(L"(%d) %s", count, (PCWSTR)triggers); 109 | return temp.Left(temp.GetLength() - 2); 110 | } 111 | return L""; 112 | } 113 | 114 | CString TaskHelper::GetRepeatPattern(IRepetitionPattern* rep) { 115 | CComBSTR duration, interval; 116 | rep->get_Duration(&duration); 117 | CString text; 118 | if (duration.Length()) 119 | text += L"Duration: " + CString(duration) + L" "; 120 | rep->get_Interval(&interval); 121 | if(interval.Length()) 122 | text += L"Interval: " + CString(interval) + L" "; 123 | VARIANT_BOOL stopAtEnd; 124 | rep->get_StopAtDurationEnd(&stopAtEnd); 125 | 126 | return text + (stopAtEnd ? L"(Stop at duration end)" : L""); 127 | } 128 | 129 | PCWSTR TaskHelper::ActionTypeToString(TASK_ACTION_TYPE type) { 130 | switch (type) { 131 | case TASK_ACTION_EXEC: return L"Run Program"; 132 | case TASK_ACTION_COM_HANDLER: return L"COM Handler"; 133 | case TASK_ACTION_SEND_EMAIL: return L"Send Email"; 134 | case TASK_ACTION_SHOW_MESSAGE: return L"Show Message"; 135 | } 136 | return L"(Unknown)"; 137 | } 138 | 139 | PCWSTR TaskHelper::StateChangeToString(TASK_SESSION_STATE_CHANGE_TYPE type) { 140 | switch (type) { 141 | case TASK_CONSOLE_CONNECT: return L"Console Connect"; 142 | case TASK_CONSOLE_DISCONNECT: return L"Console Disconnect"; 143 | case TASK_REMOTE_CONNECT: return L"Remote Connect"; 144 | case TASK_REMOTE_DISCONNECT: return L"Remote Disconnect"; 145 | case TASK_SESSION_LOCK: return L"Lock"; 146 | case TASK_SESSION_UNLOCK: return L"Unlock"; 147 | } 148 | return L"(Unknown)"; 149 | } 150 | -------------------------------------------------------------------------------- /TaskSched/TaskHelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct TaskSchedSvc { 4 | HRESULT Init(PCWSTR machineName = nullptr, PCWSTR username = nullptr, PCWSTR domain = nullptr, PCWSTR password = nullptr); 5 | 6 | ITaskService* operator->() const { 7 | return _svc.p; 8 | } 9 | 10 | private: 11 | CComPtr _svc; 12 | }; 13 | 14 | struct TaskHelper { 15 | static PCWSTR TaskStateToString(TASK_STATE state); 16 | static PCWSTR TriggerTypeToString(TASK_TRIGGER_TYPE2 type); 17 | static CString GetProcessName(DWORD pid); 18 | static CString FormatMessage(DWORD error); 19 | static CString CreateDateTimeToString(PCWSTR dt); 20 | static CComPtr GetRegistrationInfo(IRegisteredTask* task); 21 | static CString GetTaskTriggers(IRegisteredTask* task); 22 | static CString GetRepeatPattern(IRepetitionPattern* rep); 23 | static PCWSTR ActionTypeToString(TASK_ACTION_TYPE type); 24 | static PCWSTR StateChangeToString(TASK_SESSION_STATE_CHANGE_TYPE type); 25 | }; 26 | -------------------------------------------------------------------------------- /TaskSched/TaskSched.cpp: -------------------------------------------------------------------------------- 1 | // TaskSched.cpp : Defines the entry point for the application. 2 | // 3 | 4 | #include "pch.h" 5 | #include "TaskSched.h" 6 | #include "MainFrame.h" 7 | #include "SecurityHelper.h" 8 | #include 9 | 10 | CAppModule _Module; 11 | 12 | int Run(LPTSTR /*lpstrCmdLine*/ = nullptr, int nCmdShow = SW_SHOWDEFAULT) { 13 | CMessageLoop theLoop; 14 | _Module.AddMessageLoop(&theLoop); 15 | 16 | CMainFrame wndMain; 17 | 18 | if (wndMain.CreateEx() == nullptr) { 19 | ATLTRACE(_T("Main window creation failed!\n")); 20 | return 0; 21 | } 22 | 23 | wndMain.ShowWindow(nCmdShow); 24 | 25 | int nRet = theLoop.Run(); 26 | 27 | _Module.RemoveMessageLoop(); 28 | return nRet; 29 | } 30 | 31 | int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) { 32 | HRESULT hRes = ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); 33 | ATLASSERT(SUCCEEDED(hRes)); 34 | 35 | AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES); 36 | 37 | hRes = _Module.Init(nullptr, hInstance); 38 | ATLASSERT(SUCCEEDED(hRes)); 39 | 40 | ::SetThreadPriority(::GetCurrentThread(), THREAD_PRIORITY_HIGHEST); 41 | if (SecurityHelper::IsRunningElevated()) 42 | SecurityHelper::EnablePrivilege(SE_DEBUG_NAME); 43 | 44 | ThemeHelper::Init(); 45 | 46 | int nRet = Run(lpCmdLine, nCmdShow); 47 | 48 | _Module.Term(); 49 | ::CoUninitialize(); 50 | 51 | return 0; 52 | } 53 | 54 | 55 | -------------------------------------------------------------------------------- /TaskSched/TaskSched.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "resource.h" 4 | -------------------------------------------------------------------------------- /TaskSched/TaskSched.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched/TaskSched.rc -------------------------------------------------------------------------------- /TaskSched/TaskSched.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {9dec5985-367e-4504-9e18-06d116f6475e} 25 | TaskSched 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | 79 | 80 | true 81 | 82 | 83 | false 84 | 85 | 86 | 87 | Level3 88 | true 89 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 90 | true 91 | Use 92 | pch.h 93 | stdcpp20 94 | ..\WTLHelper 95 | MultiThreadedDebug 96 | 97 | 98 | Windows 99 | true 100 | 101 | 102 | _DEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) 103 | 104 | 105 | 106 | 107 | Level3 108 | true 109 | true 110 | true 111 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 112 | true 113 | Use 114 | pch.h 115 | stdcpp20 116 | MultiThreaded 117 | ..\WTLHelper 118 | 119 | 120 | Windows 121 | true 122 | true 123 | true 124 | 125 | 126 | 127 | 128 | Level3 129 | true 130 | _DEBUG;_WINDOWS;%(PreprocessorDefinitions) 131 | true 132 | Use 133 | pch.h 134 | stdcpp20 135 | ..\WTLHelper 136 | MultiThreadedDebug 137 | 138 | 139 | Windows 140 | true 141 | 142 | 143 | _DEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions) 144 | 145 | 146 | 147 | 148 | Level3 149 | true 150 | true 151 | true 152 | NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 153 | true 154 | Use 155 | pch.h 156 | stdcpp20 157 | MultiThreaded 158 | ..\WTLHelper 159 | 160 | 161 | Windows 162 | true 163 | true 164 | true 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | Create 184 | Create 185 | Create 186 | Create 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | {ae53419f-a769-4548-8e15-e311904df7df} 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 232 | 233 | 234 | 235 | 236 | -------------------------------------------------------------------------------- /TaskSched/TaskSched.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {e30b31c4-2b53-491e-8f57-769d64ccc83c} 18 | 19 | 20 | {c5a2ce5a-e8c6-40aa-8a63-9f6c2d957293} 21 | 22 | 23 | {41e6964e-6cca-48e2-9f4a-a554613d1afe} 24 | 25 | 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files 41 | 42 | 43 | Dialogs 44 | 45 | 46 | Helpers 47 | 48 | 49 | Helpers 50 | 51 | 52 | Helpers 53 | 54 | 55 | Dialogs 56 | 57 | 58 | 59 | 60 | Source Files 61 | 62 | 63 | Source Files 64 | 65 | 66 | Source Files 67 | 68 | 69 | Dialogs 70 | 71 | 72 | Helpers 73 | 74 | 75 | Source Files 76 | 77 | 78 | Dialogs 79 | 80 | 81 | 82 | 83 | Resource Files 84 | 85 | 86 | 87 | 88 | Resource Files\Icons 89 | 90 | 91 | Resource Files\Icons 92 | 93 | 94 | Resource Files\Icons 95 | 96 | 97 | Resource Files\Icons 98 | 99 | 100 | Resource Files\Icons 101 | 102 | 103 | Resource Files\Icons 104 | 105 | 106 | Resource Files\Icons 107 | 108 | 109 | Resource Files\Icons 110 | 111 | 112 | Resource Files\Icons 113 | 114 | 115 | Resource Files\Icons 116 | 117 | 118 | Resource Files\Icons 119 | 120 | 121 | Resource Files\Icons 122 | 123 | 124 | Resource Files\Icons 125 | 126 | 127 | Resource Files\Icons 128 | 129 | 130 | Resource Files\Icons 131 | 132 | 133 | Resource Files\Icons 134 | 135 | 136 | Resource Files\Icons 137 | 138 | 139 | Resource Files\Icons 140 | 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /TaskSched/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /TaskSched/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /TaskSched/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #pragma once 8 | 9 | #include "targetver.h" 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | #define NOMINMAX 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | extern CAppModule _Module; 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #if defined _M_IX86 37 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") 38 | #elif defined _M_IA64 39 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") 40 | #elif defined _M_X64 41 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") 42 | #else 43 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") 44 | #endif 45 | -------------------------------------------------------------------------------- /TaskSched/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by TaskSched.rc 4 | // 5 | #define IDR_MAINFRAME 100 6 | #define IDS_APP_TITLE 103 7 | #define IDD_ABOUTBOX 103 8 | #define IDM_ABOUT 104 9 | #define IDM_EXIT 105 10 | #define IDI_COPY 106 11 | #define IDI_ICON2 107 12 | #define IDI_REFRESH 107 13 | #define IDP_GENERAL 107 14 | #define IDI_DELETE 108 15 | #define IDI_FIND 109 16 | #define IDI_FOLDER 110 17 | #define IDI_FOLDER_OPEN 111 18 | #define IDI_PLAY 112 19 | #define IDI_PAUSE 113 20 | #define IDI_PERIOD 114 21 | #define IDI_TASK 115 22 | #define IDR_CONTEXT 116 23 | #define IDI_TASK_DISABLED 117 24 | #define IDI_STOP 118 25 | #define IDI_GENERIC 119 26 | #define IDI_CANCEL 120 27 | #define IDI_YES 121 28 | #define IDI_ACTION 122 29 | #define IDI_ICON5 123 30 | #define IDI_TIMER 123 31 | #define IDC_NAME 1000 32 | #define IDC_PATH 1001 33 | #define IDC_AUTHOR 1002 34 | #define IDC_DESC 1003 35 | #define IDC_DATA 1004 36 | #define ID_FILE_RUNASADMIN 32771 37 | #define ID_VIEW_REFRESH32772 32772 38 | #define ID_EDIT_COPY32773 32773 39 | #define ID_TASK_ENABLE 32774 40 | #define ID_TASK_DELETE 32775 41 | #define ID_TASK_EXPORT 32776 42 | #define ID_TASK_RUN 32777 43 | #define ID_TASK_PROPERTIES 32778 44 | #define ID_FILE_RUNNINGTASKS 32779 45 | #define ID_FOLDERS_CREATE 32780 46 | #define ID_FOLDERS_DELETE 32781 47 | #define ID_VIEW_REFRESHALL 32785 48 | #define ID_FILE_NEWTASK 32786 49 | #define ID_TASK_STOP 32787 50 | 51 | // Next default values for new objects 52 | // 53 | #ifdef APSTUDIO_INVOKED 54 | #ifndef APSTUDIO_READONLY_SYMBOLS 55 | #define _APS_NO_MFC 1 56 | #define _APS_NEXT_RESOURCE_VALUE 125 57 | #define _APS_NEXT_COMMAND_VALUE 32788 58 | #define _APS_NEXT_CONTROL_VALUE 1005 59 | #define _APS_NEXT_SYMED_VALUE 110 60 | #endif 61 | #endif 62 | -------------------------------------------------------------------------------- /TaskSched/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // // Including SDKDDKVer.h defines the highest available Windows platform. 4 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 5 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 6 | #include 7 | -------------------------------------------------------------------------------- /TaskSched1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/TaskSched/93be16cfc3c1a14f7488efad048b683225575f49/TaskSched1.png --------------------------------------------------------------------------------