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

Reply ↓  Report •

#1
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


Reply ↓  Report •

#2
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.

Reply ↓  Report •
Related Solutions


Ask Question