AasimPathan Posted March 14, 2019 Share Posted March 14, 2019 I am using the following script to restart computers at a specific time each day using Scheduled Task to create the event that would call the Script (Compiled .exe) #include <AutoItConstants.au3> #include <Misc.au3> #NoTrayIcon ;Begin Script Local $L_V_Scalar_Variant_Message = "This computer will restart in the next 2 minutes; save all open documents immediately!" SplashTextOn("Restart Computer", $L_V_Scalar_Variant_Message, -1, -1, -1, -1, $DLG_TEXTLEFT, "", 24) Sleep(120000) ;120 seconds M_S_Restart() SplashOff() Func M_S_Restart() Shutdown(6) EndFunc When i run the script by double clicking on the exe it just works fine. Now i've added the complied script to Scheduled Task and set it to run daily at 4 am. User should be notified, if they are logged in or in locked state. but apparently the user doesnot get any notification and the computer is restarted which is a big problem, as their work is not saved. I am attaching the XML code for the Task. <?xml version="1.0" encoding="UTF-16"?> <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"> <RegistrationInfo> <Description>Restart computer daily at 4AM</Description> <URI>\U_A_A_WindowsRestartCore</URI> </RegistrationInfo> <Triggers> <CalendarTrigger> <StartBoundary>2019-03-08T04:00:00+00:00</StartBoundary> <Enabled>true</Enabled> <ScheduleByDay> <DaysInterval>1</DaysInterval> </ScheduleByDay> </CalendarTrigger> </Triggers> <Principals> <Principal id="Author"> <UserId>S-1-5-21-209663586-3969970584-2577160918-9632</UserId> <LogonType>InteractiveToken</LogonType> <RunLevel>LeastPrivilege</RunLevel> </Principal> </Principals> <Settings> <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy> <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries> <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries> <AllowHardTerminate>true</AllowHardTerminate> <StartWhenAvailable>false</StartWhenAvailable> <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable> <IdleSettings> <Duration>PT10M</Duration> <WaitTimeout>PT1H</WaitTimeout> <StopOnIdleEnd>true</StopOnIdleEnd> <RestartOnIdle>false</RestartOnIdle> </IdleSettings> <AllowStartOnDemand>true</AllowStartOnDemand> <Enabled>true</Enabled> <Hidden>false</Hidden> <RunOnlyIfIdle>false</RunOnlyIfIdle> <WakeToRun>false</WakeToRun> <ExecutionTimeLimit>PT72H</ExecutionTimeLimit> <Priority>7</Priority> </Settings> <Actions Context="Author"> <Exec> <Command>C:\U_BayVL00\Programs\U_A_A_WindowsRestartCore.exe</Command> </Exec> </Actions> </Task> Any solution? Link to comment Share on other sites More sharing options...
Developers Jos Posted March 14, 2019 Developers Share Posted March 14, 2019 (edited) That is not really an AutoIt3 Question, but rather a Windows Scheduler one. Maybe: https://docs.microsoft.com/en-us/windows/desktop/taskschd/taskschedulerschema-hidden-settingstype-element ? Jos Edited March 14, 2019 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
AasimPathan Posted March 14, 2019 Author Share Posted March 14, 2019 Hidden is false as you can see in the XML code i added in the post. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 14, 2019 Developers Share Posted March 14, 2019 Understood.. but like I said, this is not really an Autoit3 question but rather a Window question. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Bert Posted March 14, 2019 Share Posted March 14, 2019 Simple solution to this problem - create a second exe that launches your rebooter at the time you want using the task scheduler. The EXE launcher will be hidden yet your rebooter won't be. AasimPathan 1 The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
AasimPathan Posted March 15, 2019 Author Share Posted March 15, 2019 Thank you @Bert That was a better option, I created a simple script that calls the other script - task done! Link to comment Share on other sites More sharing options...
AasimPathan Posted March 25, 2019 Author Share Posted March 25, 2019 On 3/14/2019 at 4:54 PM, Bert said: Simple solution to this problem - create a second exe that launches your rebooter at the time you want using the task scheduler. The EXE launcher will be hidden yet your rebooter won't be. Hi Bert, I seem to have spoken too soon. Today I deployed the schedule task that calls the other exe that should show up the message that system is restarting. But when I ran the scheduled task it didn't pop up the message neither. basically there are 2 EXE files The RestartScheduler calls the RestartCore which should display the popup notification, and when i run it manually it does and works as expected. But running the same in Task Scheduler, does not show any GUI. even though i can see it running in Task Manager, i even tried changing from SYSTEM to my Username and that didn't help either. I am adding the code here if someone can help me tweak this, I would appreciate it a lot. ;This script is necessary even though the only thing that it does is call another script because if the other script ran directly it would run under the user account and therefore the message would not appear on the logged-on user's screen. #include <AutoItConstants.au3> #include <Misc.au3> #NoTrayIcon M_S_RestartWindows() Func M_S_RestartWindows() Run("C:\Programs\U_A_A_WindowsRestartCore.exe") EndFunc #include <AutoItConstants.au3> #include <Misc.au3> #NoTrayIcon Local $sMessage = "This computer will restart in the next 2 minutes; save all open documents immediately!" SplashTextOn("Restart Computer", $sMessage, -1, -1, -1, -1, $DLG_TEXTLEFT, "", 24) Sleep(120000) ;120 seconds M_S_Restart() SplashOff() Func M_S_Restart() Shutdown(6) EndFunc Link to comment Share on other sites More sharing options...
Nine Posted March 25, 2019 Share Posted March 25, 2019 (edited) Well I just tested it directly (without using a second .exe) and it worked fine : splash showed out as intended. Use your code except for the restart. Compiled x86. Win7. So the problem is not autoit, but the way the task has been scheduled. Edited March 25, 2019 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
AasimPathan Posted March 26, 2019 Author Share Posted March 26, 2019 @Nine can you try creating a scheduled task in windows & see if you can still see the GUI as you do when running the exe? Link to comment Share on other sites More sharing options...
Nine Posted March 26, 2019 Share Posted March 26, 2019 (edited) 7 hours ago, AasimPathan said: @Nine can you try creating a scheduled task in windows & see if you can still see the GUI as you do when running the exe? This is what I did. I created a base task running every day at a few minutes after creation and it worked perfectly. Edited March 26, 2019 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
AasimPathan Posted March 28, 2019 Author Share Posted March 28, 2019 On 3/26/2019 at 5:59 PM, Nine said: This is what I did. I created a base task running every day at a few minutes after creation and it worked perfectly. Change it to a different user and please test it if you can. I created the task as the local user and ran it and it works just fine. but remember we are doing this through GPO and it uses an administrator account, so when i changed the user in the scheduled task it doesn't work. Link to comment Share on other sites More sharing options...
Nine Posted March 28, 2019 Share Posted March 28, 2019 Works like a charm. Create the task with User A (with admin rights). Logged off. Logged in with User B. And the splash showed up at the specified time. No problem. But I do not use GPO tho. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
AasimPathan Posted March 28, 2019 Author Share Posted March 28, 2019 can you export and paste the xml from schedule task? maybe something is wrong on my end. or maybe it works in windows 7 and not 10 Link to comment Share on other sites More sharing options...
Nine Posted March 28, 2019 Share Posted March 28, 2019 5 minutes ago, AasimPathan said: can you export and paste the xml from schedule task? maybe something is wrong on my end. or maybe it works in windows 7 and not 10 expandcollapse popup<?xml version="1.0" encoding="UTF-16"?> <Task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"> <RegistrationInfo> <Date>2019-03-28T08:01:37.4475448</Date> <Author>NINE\Nine</Author> </RegistrationInfo> <Triggers> <CalendarTrigger> <StartBoundary>2019-03-28T08:11:00</StartBoundary> <Enabled>true</Enabled> <ScheduleByDay> <DaysInterval>1</DaysInterval> </ScheduleByDay> </CalendarTrigger> </Triggers> <Principals> <Principal id="Author"> <GroupId>S-1-5-32-545</GroupId> <RunLevel>LeastPrivilege</RunLevel> </Principal> </Principals> <Settings> <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy> <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries> <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries> <AllowHardTerminate>true</AllowHardTerminate> <StartWhenAvailable>false</StartWhenAvailable> <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable> <IdleSettings> <StopOnIdleEnd>true</StopOnIdleEnd> <RestartOnIdle>false</RestartOnIdle> </IdleSettings> <AllowStartOnDemand>true</AllowStartOnDemand> <Enabled>true</Enabled> <Hidden>false</Hidden> <RunOnlyIfIdle>false</RunOnlyIfIdle> <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession> <UseUnifiedSchedulingEngine>false</UseUnifiedSchedulingEngine> <WakeToRun>false</WakeToRun> <ExecutionTimeLimit>P3D</ExecutionTimeLimit> <Priority>7</Priority> </Settings> <Actions Context="Author"> <Exec> <Command>C:\Applications\AutoIt\TaskScheduler.exe</Command> </Exec> </Actions> </Task> “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
AasimPathan Posted March 28, 2019 Author Share Posted March 28, 2019 Well thank you, that did the trick I suppose, changing the user from using an administrative account i set it to "Users" and it worked. Link to comment Share on other sites More sharing options...
Nine Posted March 28, 2019 Share Posted March 28, 2019 24 minutes ago, AasimPathan said: Well thank you, that did the trick I suppose, changing the user from using an administrative account i set it to "Users" and it worked. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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