添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
){outline:none;box-shadow:none;}select::-ms-expand{;}:root,:host{--chakra-vh:100vh;}@supports (height: -webkit-fill-available){:root,:host{--chakra-vh:-webkit-fill-available;}}@supports (height: -moz-fill-available){:root,:host{--chakra-vh:-moz-fill-available;}}@supports (height: 100dvh){:root,:host{--chakra-vh:100dvh;}}
Link to home
Create Account Log in
Avatar of Jerome Slaughter
Jerome Slaughter 🇺🇸

asked on

How to fix a last run result error (0x1 - Incorrect function.(1)) in task scheduler
I am trying to get a successful GPO scheduled task (simple logoff script .bat file) to run from my Windows Server 2008 R2 server to a single test machine before I implement it to a bigger group of Windows 7 workstations on my network. I haven't had any luck. I can run the script manually on the Windows 7 Test machine but I'm having problems getting it to execute through GPO from the server to the test machine. I keep getting a Last Run Result message of 0x1 - Incorrect function.(1). I added code in the log off script to produce a log to give me more information and that's where I am getting the Incorrect function.(1) message.
My simple logoff script is just shutdown.exe /f /l
I've tried some of the tips from the internet for different ways to setup the scheduled task to no avail.
The internet says that the last run result of 0x1 means: Incorrect function. Indicates that Action has attempted to execute non-recognized command in Windows command prompt cmd.exe.
What does this mean exactly?
Any suggestions would be greatly appreciated.
Avatar of Joe Winograd
Two ideas:
(1) In the scheduled task, make sure the Run with highest privileges box is ticked.
(2) Fully qualify the command, that is:
c:\Windows\System32\shutdo wn.exe
Regards, Joe
Avatar of Jerome Slaughter
Jerome Slaughter 🇺🇸

ASKER

@ Joe Winograd ... thanks but I've done both of your suggestions even before posting my question.
Any other ideas? It's just been a pain to get it to work through group policy.
ASKER CERTIFIED SOLUTION
Avatar of Joe Winograd
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of NVIT
NVIT 🇺🇸
Just to verify...Is your task's Action set as...
Program: shutdown.exe
Add Arguments: /f /l
Avatar of Jerome Slaughter
Jerome Slaughter 🇺🇸

ASKER

I always use the " Run whether user is logged on or not " option instead of the other. The whole idea of this is to run this log off command through Group Policy on our network to automatically the force log off of users during off hours.
Besides using the shutdown command and getting the last run result of 0x1:
1. I have a simple .bat logoff script i've tried which also gives the last run result of 0x1.
2. I have a simple .VBS log off script as well that says it runs successfully in task scheduler but the action of logging off doesn't occur.
Avatar of Jerome Slaughter
Jerome Slaughter 🇺🇸

ASKER

@ NewVillageIT
The task action in task scheduler is set as you displayed above. Still does not work through GPO or if I run a simple task scheduler event directly on the test machine. Still getting the 0x1 error.
Avatar of Joe Winograd
> whole idea of this is to run this log off command through Group Policy on our network to automatically the force log off of users during off hours
I don't know why your logoff and shutdown scripts aren't working, but here's a different approach that you may want to consider:
http://community.spiceworks.com/how_to/4975-force-user-log-off-rds-server-2008
Avatar of Jerome Slaughter
Jerome Slaughter 🇺🇸

ASKER

@ Joe Winograd
the link above - http://community.spiceworks.com/how_to/4975-force-user-log-off-rds-server-2008
is coming up as a blank page for me for some reason.....
Avatar of NVIT
NVIT 🇺🇸
I can run the script manually on the Windows 7 Test machine... Do you mean you run it from the CMD prompt works?
...but as same user...
does not work through GPO or if I run a simple task scheduler event directly on the test machine
Avatar of Joe Winograd
Joe Winograd 🇺🇸
That link comes up fine here in Firefox 35, Chrome 40, and IE11, so it must be something in your environment. I considered creating a PDF of it for you, but it is copyrighted material and doing that would be in violation of Spiceworks Terms of Use . So you'll have to find a way to access it yourself, and it seems to be exactly what you want. Regards, Joe
Avatar of Jerome Slaughter
Jerome Slaughter 🇺🇸

ASKER

@ NewVillageIT
"I can run the script manually on the Windows 7 Test machine" ............
What I meant by this was I have tested several things on the local machine and via the server. Details are below:
1. I can successfully perform "shutdown /f /l" in the command prompt on the local machine BUT NOT via Task Scheduler locally or Task Scheduler through domain GPO on the server. I use the same domain admin account in each case and I get the same error of 0x1.
2.  I can successfully copy the simple logoff.bat or logoff.vbs scripts I have to the local test machine and run them via the command prompt on the local machine or by double clicking the scripts and it successfully logs me off. However, I've had NO LUCK running these scripts via Task Scheduler locally or Task Scheduler through domain GPO on the server. I use the same domain admin account in each case and I get the same error of 0x1.
3. I can succesfully double click and run the Windows OS provided logoff.exe in the C:\Windows\System32\logoff .exe and it logs me off. However, I've had NO LUCK running this via Task Scheduler locally or Task Scheduler through domain GPO on the server. I use the same domain admin account in each case and I get the same error of 0x1.
Still looking for a good solution to my problem as I am trying everything...
Avatar of NVIT
NVIT 🇺🇸
Have you tried other scheduled tasks? Do they run?
Avatar of Jerome Slaughter
Jerome Slaughter 🇺🇸

ASKER

@ Joe Winograd
Was able to look at the link you provided via Firefox but the suggestion in the link is not going to help me because I can only apply the "Enforce User Log off GPO" setting via the Default Domain Policy not in a different GPO which I prefer. Our Default Domain Policy is tied to a mix of domain users (standard users and special users) and other domain policies that affect all users. We are only looking to automatically log off the standard users after hours in this case.
Avatar of Jerome Slaughter
Jerome Slaughter 🇺🇸

ASKER

@ NewVillageIT
Yes we have other Task Scheduled Group Policies that automatically run successfully daily. Not sure why I can't get this to run.
Avatar of Joe Winograd
> Still looking for a good solution to my problem as I am trying everything...
Have you been able to access the Force User Log Off (RDS, Server 2008) article? Its Introduction says that it provides steps showing "how to set log-on hour restrictions and force a user log off when the hours expire." Your browser should certainly be able to view that page. Regards, Joe
Avatar of Joe Winograd
Our messages just crossed — I'm glad to hear you were able to access it with Firefox, but disappointed that it won't solve your problem. I'll continue to give it some thought, but am out of ideas right now.
Avatar of Jerome Slaughter
Jerome Slaughter 🇺🇸

ASKER

I even get the "0x1" last run result error message in task scheduler when I try to do a simple display message which doesn't even involve a script. That should atleast work. Now it's really getting frustrating.
Avatar of NVIT
NVIT 🇺🇸
Try changing General, Change User or Group. Enter: System
Avatar of Jerome Slaughter
Jerome Slaughter 🇺🇸

ASKER

still getting the "0x1" last run result error for system user
Avatar of NVIT
NVIT 🇺🇸
If you haven't already tried this, as another test, basically, make another task w/ same setup.
- Make a new task w/ different name.
- Use same values as the other task. i.e.:
-- Program: shutdown.exe
-- Add Arguments: /f /l
-- Change User or Group: System
Run it.
Avatar of Joe Winograd
> I even get the "0x1" last run result error message in task scheduler when I try to do a simple display message
That answers my question from way-back-when (in my second post) as to what happens if you replace the shutdown command with something else — in other words, is the problem specific to the shutdown command or is it something more general? Clearly, it is a more general problem, probably related to permissions, but since Run with highest privileges and Run only when user is logged on are both ticked, I don't know what else the problem could be with respect to permissions. Maybe permissions on folders? Could a firewall be the problem? Yes, very frustrating!
Avatar of Jerome Slaughter
Jerome Slaughter 🇺🇸

ASKER

@ NewVillageIT
tried your latest suggestion above and still getting the last run result of "0x1"
Avatar of Jerome Slaughter
Jerome Slaughter 🇺🇸

ASKER

I actually got to the solution after trial and error, information from this link:
http://blogs.technet.com/b/askds/archive/2010/08/24/forcing-afterhours-user-logoffs.aspx
plus some of the expert suggestions above!
I was selecting Run whether user is logged on or not vs Run only when user is logged on as @Joe Winograd suggested above.
Selecting Run only when user is logged on in Task Scheduler works like a champ!
Thanks to all!
Avatar of NVIT
NVIT 🇺🇸
Glad you got it working, jslaught...
Avatar of Joe Winograd
You're very welcome. That's great news! I was bitten a long time ago by not having the Run only when user is logged on option and now use it for all of my scheduled tasks. Glad to hear that was the trick for you. Regards, Joe
Avatar of Jerome Slaughter
Jerome Slaughter 🇺🇸

ASKER

Great suggestions from the experts. found the answer to my issue.
Avatar of ganesh kumar
i was trying to apply the corrections listed above .. but my problem is its simply showing the administrator password is  wrong . or am not authorized like sentence. but the thing is am the administrator of this server,  and am accessing the server by remote . i tried running manually its running but the errors still the same . in my case  the error is in back up sector ..and need to be cleared asap . any answers and sujjessions will be greatly appeciated
Avatar of Joe Winograd
Hi ganesh,