mowgli82 Posted December 17, 2015 Posted December 17, 2015 Hi Guys, I am trying to set up a scheduled task to display a reminder on all PC's, the problem is the dialogue box doesn't seem to appear on the users desktop, I have searched the net but not found a solution that works. I have tried changing the user the task runs as, setting as a machine scheduled task and a user scheduled task using msg.exe and various vbs methods but nothing seems to be working. This is on Windows 7. Any help appreciated. Thanks
nickalmond Posted December 17, 2015 Posted December 17, 2015 Hello. To try and break this down; Do you know if the issue is with the scheduled tasks not running or if the issue is with the dialogue box not running? Do you have any policies in place that may prevent VBS or CMD scripts from running on non-admin accounts? I have used a package called AutoIT to create an EXE file in the past for other purposes. If you do have restrictions on the account, this may be a suitable way around this without changing any of your existing setup; Basic instructions if you haven't used AutoIT before; Download and install AutoIT from https://www.autoitscript.com/site/autoit/downloads/ Insert the following code with your message; MsgBox (0, "Notification", "This is a test") Select Tools > Compile And select your output location. Change your schedule to point to the exe on the network share and you should be good to go. Hopefully this helps! Nick
mowgli82 Posted December 17, 2015 Author Posted December 17, 2015 Hi Nick, The task runs without errors but I think its something to do with the task schedular not allowing interaction with the desktop. I will give your suggestion a try. Thanks Simon
LeMarchand Posted December 17, 2015 Posted December 17, 2015 The task runs without errors but I think its something to do with the task schedular not allowing interaction with the desktop. I will give your suggestion a try. Please post if you get this working! I've been trying off-and-on to get a "This PC is shutting down" message to work, but the methods that seem to work aren't always visible or don't open at a large enough size. Using an HTA file had a large enough/on top/in your face message, but IIRC I could never get it to work as a scheduled task. One of my projects for next year is to organise a shut down/update policy for an ICT suite, so getting a message up would be very useful.
nickalmond Posted December 18, 2015 Posted December 18, 2015 Please post if you get this working! I've been trying off-and-on to get a "This PC is shutting down" message to work, but the methods that seem to work aren't always visible or don't open at a large enough size. Using an HTA file had a large enough/on top/in your face message, but IIRC I could never get it to work as a scheduled task. One of my projects for next year is to organise a shut down/update policy for an ICT suite, so getting a message up would be very useful. Hello. I have set a GPO schedule to open an .exe for 13:00 today so will see if that works and get back to you. With regards to your shutdown - I have just put together the following AutoIT script which will hopefully do what you want - be aware that if you run this within AutoIT - it WILL shut down your computer after 30 seconds unless you cancel / close it down - you have been warned . #Include #include #include ;~ VARIABLES $COUNTDOWN = 30000 ;MS $GUIWIDTH = 370 $GUIHEIGHT = 84 ;~ CREATE GUI $GUI = GUICreate("Shutdown", $GUIWIDTH, $GUIHEIGHT) ;~ GUI MESSAGE $MESSAGE = "Your computer will shut down in " & ROUND($COUNTDOWN/1000,0) & " seconds" ;~ GUI LABEL $MESSAGELBL = GUICtrlCreateLabel($MESSAGE, 0, 10, $GUIWIDTH, 30, $SS_CENTER) GUICtrlSetFont($MESSAGELBL, 11, 600) ;~ GUI Button $CANCELBTN = GUICtrlCreateButton("Cancel Shutdown", 120, 44, 130, 30) ;~ GUI SET VISIBLE GUISetState(@SW_SHOW, $GUI) ;~ WHILE LOOP While 1 $COUNTDOWN = $COUNTDOWN-100 Sleep (100) ;~ UPDATE GUI MESSAGE $MESSAGE = "Your computer will shut down in " & ROUND($COUNTDOWN/1000,0) & " seconds" GUICtrlSetData($MESSAGELBL, $MESSAGE) ;~ IF COUNTDOWN EQUALS 0 THEN SHUTDOWN If $COUNTDOWN = 0 Then Sleep(1000) Shutdown (1) Exit EndIf ;~ LISTEN FOR MESSAGE $msg = GUIGetMsg() Switch $msg Case $CANCELBTN Exit Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd 1
LeMarchand Posted December 18, 2015 Posted December 18, 2015 @nickalmond - thanks for that. Be interested if you do get a suitable pop up. The shut down wasn't a problem, it was getting a suitable notice for the users that it was going to happen. I thought they were being unobservant, but when I experimented I found that the notification window was quite easy to "lose" if the machine was in use.
nickalmond Posted December 18, 2015 Posted December 18, 2015 No problem at all. I have made the font and window size on the larger size but if you still think this is too small, it can be easily increased by simply changing the following variables; $GUIWIDTH = 370 $GUIHEIGHT = 84 and GUICtrlSetFont($MESSAGELBL, 11, 600) 11 = font size, 600 = font weight Obviously this wouldn't prevent someone opening a window on top and missing it this way but its not bad. My main concern is that someone isn't in the room at the time the script is launched and the system is forcibly shut down resulting in said member loosing work. This is obviously your call but i would personally be a little cautious. We currently shut our machines down at 6:15pm (just after the school shuts) using the Impero management software - this way we know everyone has finished work. Good luck with it! Ooo - also, 13:00 came and went and no signs of the scheduled task. Will take another look on Monday.
nickalmond Posted December 18, 2015 Posted December 18, 2015 Hello. Quick update which is worth a try; The Scheduled Task has been created correctly via GPO. Under the task history, I had an error stating it couldn't run. It was down as runnning under the administrator account. Simply changing this to 'BUILTIN\Users' resolved the issue. Give it a try and let me know how you get on. Nick 1
mowgli82 Posted January 6, 2016 Author Posted January 6, 2016 ok so this is what I have so far: Set WSHShell = WScript.CreateObject("WScript.Shell") Set oFS = CreateObject("Scripting.FileSystemObject") 'Open a text file of computer names 'with one computer name per line Set oTS = oFS.OpenTextFile("C:\RegistrationTest\Computers.txt") 'go through the text file Do Until oTS.AtEndOfStream 'get the next computer name 'store it in variable strCompname strCompname = oTS.ReadLine WshShell.Run "msg * /server:"& strCompname & "Registration is now OPEN" Loop 'close the text file oTS.Close If i replace the strcompname with the name of a pc it works fine but I don't think its getting the information from the text file and putting it in to the variable - any ideas?
Oaktech Posted January 6, 2016 Posted January 6, 2016 This seems like a hell of a lot of work... I'm using just using PSShutdown with the @file -t -c and -m options tolist computers, select a 30 second timer, the ability to cancel a shutdown and to display a message. https://technet.microsoft.com/en-us/sysinternals/psshutdown.aspx
mowgli82 Posted January 6, 2016 Author Posted January 6, 2016 Hi @Oaktech, I personally dont want to shutdown the computers I just want to display a message on certain workstations at certain time of the day - scheduled task won't allow that as the popup box wont seem to run in the user space.
mowgli82 Posted January 6, 2016 Author Posted January 6, 2016 (edited) I managed to get this working - the string in my variable wasn't formatted correctly - it needed to be this: WshShell.Run "msg * /server:"& strCompname & " Registration is now OPEN" I have a scheduled task on the server which runs this. Edited January 6, 2016 by mowgli82
LeMarchand Posted January 13, 2016 Posted January 13, 2016 Hello. Quick update which is worth a try; The Scheduled Task has been created correctly via GPO. Under the task history, I had an error stating it couldn't run. It was down as runnning under the administrator account. Simply changing this to 'BUILTIN\Users' resolved the issue. Give it a try and let me know how you get on. Nick Finally got around to looking at this again today. Changing the account as above meant that the .hta I was experimenting with many moons ago displays properly on top of all other windows and is HUGE, so they can't claim they didn't notice it. Just got to tweak the visuals a bit and then suss out the rest of my shutdown week nights/wake up for updates at weekend/reboot to apply updates masterplan... (Just shutting down didn't seem to "Shutdown + Apply Updates").
dapaulio Posted January 13, 2016 Posted January 13, 2016 Which user are you running the task under? I think It will be running but on the user that you set in the task scheduler. If you change the scheduled task user to reflect your test user account you logging on as, does it show?
LeMarchand Posted January 14, 2016 Posted January 14, 2016 Which user are you running the task under? I think It will be running but on the user that you set in the task scheduler. If you change the scheduled task user to reflect your test user account you logging on as, does it show? I you mean me, doesn't matter. Changing the account to BUILTIN\Users sees to do the trick for everyone. Though have just discovered that the window doesn't display on top if the there is keyboard or mouse activity at the precise moment it's scheduled to appear. Might have to live with this!
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