Trouble making command work as scheduled task

December 5, 2018 at 11:28:53
Specs: Windows 10, i7-7700K@4.2GHz, 32 GB
Here I am again, stuck trying to solve a programming problem. With my batch file issue posted here in October, "hidde663" was very, very helpful, and solved the problem for me. Hoping someone can do the same here.

I created a script which opens a window and displays a message reminding a user to log off when his session is finished. Here is the script, which runs without problem if I enter it on the command line: C:\Windows\System32\mshta "javascript:var sh=new ActiveXObject( 'WScript.Shell' ); sh.Popup( 'PLEASE BE SURE TO LOG OFF WHEN YOUR SESSION HAS ENDED TO PRESERVE OUR DATA INTEGRITY...', 0, 'PLEASE LOG OFF WHEN FINISHED', 64 );close()"

I planned to have it run whenever a user logs in, and pop up the window every 7 minutes for an hour. I thought "schtasks" would do this, and I thought I had the syntax the way it should be, because when I enter the following on the command line, the message is that the task has successfully been created: Schtasks /CREATE /SC MINUTE /NP /MO 7 /DU 01:00 /TN Logoff-Reminder /TR "mshta 'javascript:var sh=new ActiveXObject( 'WScript.Shell' ); sh.Popup( 'PLEASE BE SURE TO LOG OFF WHEN YOUR SESSION HAS ENDED TO PRESERVE OUR DATA INTEGRITY...', 0, 'PLEASE LOG OFF WHEN FINISHED', 64 );close()'"

But that's just the first step, because the task hasn't been started. Just to test if it works at all, I highlight the task in Task Scheduler and click "Run". The status changes to "Running", but no message box ever appears.

What I really want is for the message to start popping up when a new user logs on, so I went to the Group Policy editor >Administrative Templates > System > Logon and enabled "Run the programs at user logon". But after pasting the "schtasks /create..." string in the "Value" field and saving, etc, when I switch users nothing happens.

Not being a programmer, I don't readily see what is causing the problem, but I'm hoping that after I've tried for two days to get this to work, one of you will probably look at it and see an obvious mistake I'm making.

Thanks very much for your help.

See More: Trouble making command work as scheduled task

Report •

December 5, 2018 at 11:51:57
Instead of harassing your end users, consider implementing an auto logoff instead.

How To Ask Questions The Smart Way

Report •

December 5, 2018 at 12:03:38
Yes, I can implement a command that checks how long the system has been idle and if no activity for "X" minutes, logs them off automatically. However, it logs them off no matter what they are doing, with no warning. I was hoping to condition the users (there are only 5; I know them all well; they will not feel "harassed"; and they just need to get in the habit of logging off when they are finished. I am only planning to run this for a month or so.

Report •

December 12, 2018 at 12:33:37
The site continues to ask me to select a "best answer". Unfortunately, the only response was a smart-ass comment from Razor2.3, so at this point, I don't consider that I have received an "answer" at all.

Report •

Related Solutions

December 12, 2018 at 13:48:42
IndigoJon: they will not feel "harassed"
Are you sure? 'Cause that sounds like the sort of pranks I pull on my coworkers, and they always seem to feel harassed. Especially since a popup steals user input. Meaning once they notice it, they have to stop what they're attempting, deal with the dialog box, find out how far back they need to restart, and start from there. It's not a zero-cost friendly warning, and it's happening every 7 minutes. Until the users realize they can just hide the popup and stop the annoyances.

Your problem is two fold. First, the task is not running in the user's session. It's running in a non-interactive environment, as whichever account ran the schtasks line. You have to specify you want it interactive. Second, schtasks replaces single quotes with double quotes. This breaks your javascript and means you'll have to create the task some other way (GUI), or create a file.

The point of a screensaver is to have Windows keep track of idle time, not you. But if you're worried about signing out without warning, it wouldn't take too much programming skill to make a custom screensaver logout with a cancelable warning.

All that said, if this is some shared workstation, a label maker is $20 and labels have no problem sticking to monitors.

How To Ask Questions The Smart Way

Report •

Ask Question