How do I add 'if restart/log off:continue script''
Hi I am combing two scripts; one that removes local admin from the logged in user, then run ksleep for 10 minutes, then run the script that removes admin from local user. The problem is; if the user restarts at any time during the script, it breaks:
The idea is to grant admin for around 1.5 hours for short installs and 4 hours for installations of our software using ksleep between the two scripts. But as I mention, if there is a log off/reboot anywhere during the job it fails.
Thanks for any help.
0 Comments
[ + ] Show comments
Answers (1)
Please log in to answer
Posted by:
SMal.tmcc
7 years ago
I commented on your other question also. Create a batch file that runs the remove rights portion and add that as a dependency. Use Schtasks,exe to make a one time task that runs that batch file at the time you want. The down side is you will need to modify the line that creates the scheduled task to set the time properly each time you use it.
https://msdn.microsoft.com/en-us/library/windows/desktop/bb736357(v=vs.85).aspx
to point the task to the batch file in the kace directories for the /TR taskrun switch
point at your kscript you made from the script page point to get the id.
then modify that script line that creates the scheduled task to include that id path
/TR C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\416\remove.bat
https://msdn.microsoft.com/en-us/library/windows/desktop/bb736357(v=vs.85).aspx
to point the task to the batch file in the kace directories for the /TR taskrun switch
point at your kscript you made from the script page point to get the id.
then modify that script line that creates the scheduled task to include that id path
/TR C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\416\remove.bat