enjay Posted December 16, 2011 Posted December 16, 2011 I have set up a scheduled task on the server which runs a batch file containing loads of psshutdown.exe -blah commands. This runs fine when set to run "only if the user is logged in", but doesn't run when set to run regardless or whether they're logged in or not. Any ideas why that might?
saundersmatt Posted December 16, 2011 Posted December 16, 2011 I've seen this recently. Have you ensured that UAC is disabled on the server? Matt
Mcshammer_dj Posted December 16, 2011 Posted December 16, 2011 have you selected for the task to run on request(server2008) Have you selected run with highest Privledges
IanT Posted December 16, 2011 Posted December 16, 2011 I use a VB Script todo my shutdown in scheduled task: strComputer = "." ' Local Computer Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}\\" & _ strComputer & "\root\cimv2") Set colOs = objWMIService.ExecQuery("Select * from Win32_OperatingSystem") For Each objOs in colOs objOs.Win32Shutdown(1) Next Works everytime!
enjay Posted January 6, 2012 Author Posted January 6, 2012 The task is set to run on demand, but wasn't set to "highest privileges"; I've changed that and will see what happens later. UAC is set to "never notify"; I don't see how to actually disable it - where is that set (Server 2008 R2) and is it a good idea to disable it on a server?
enjay Posted January 16, 2012 Author Posted January 16, 2012 Still doesn't work, even with "run with highest privileges" enabled. It will only run when set to "run only when user is logged in"; if I set it to run regardless, it won't run even when triggered manually whilst logged in.
Davit2005 Posted January 16, 2012 Posted January 16, 2012 I have set up a scheduled task on the server which runs a batch file containing loads of psshutdown.exe -blah commands. This runs fine when set to run "only if the user is logged in", but doesn't run when set to run regardless or whether they're logged in or not. Any ideas why that might? Have a look at Shutdownertron by PowdarMonkey. It is distributable by Policy (MSI) and there is an adm file to enable things like enable a logged on user to cancel the task, set the shutdown time etc. Just installed at my site in one classroom and works with Windows 7.
saundersmatt Posted January 16, 2012 Posted January 16, 2012 Enjay; When you try to run the task manually and it fails, what is the code in the "Last run result" column. Matt
enjay Posted January 17, 2012 Author Posted January 17, 2012 It fails with a result of 0x1. I think this is something to do with the script itself, not the scheduled task, as I have other tasks set to run regardless of logged on user, and those run fine. The task runs a batch file which looks like: "\\server_name\IT Support Dept$\Applications\PsTools\psshutdown.exe" -k -c -f -t 60 -n 3 -m "This computer is about to turn off - please click cancel if you wish to carry on working." \\ICT1-01 "\\server_name\IT Support Dept$\Applications\PsTools\psshutdown.exe" -k -c -f -t 60 -n 3 -m "This computer is about to turn off - please click cancel if you wish to carry on working." \\ICT1-02 etc etc Anyone suggest anything which could cause that to only run when set to "only run when use is logged in"?
saundersmatt Posted January 17, 2012 Posted January 17, 2012 Enjay, can you try explicity delegating full control permissions to the folder and batch file for the user you're trying to run the task as. Matt 1
enjay Posted January 17, 2012 Author Posted January 17, 2012 The user is a domain admin, so I don't think it is that. Also, if it were a rights issue, it would stop it however the task were set to run, no?
saundersmatt Posted January 17, 2012 Posted January 17, 2012 I know it seems nonsensical, but it has fixed things for me in the past. Humour me? Matt
enjay Posted January 17, 2012 Author Posted January 17, 2012 Sorted. Not a permissions thing in the way you were thinking, @saundersmatt, but permissions nonetheless - I moved the batch file and executable which the task was running to sit on the same server as it was scheduled on, and it is now running. Thanks for pointing me in the right direction.
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