Solved

How to fix a last run result error (0x1 - Incorrect function.(1)) in task scheduler

Posted on 2015-02-03
29
11,381 Views
Last Modified: 2016-09-30
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.
0
Comment
Question by:jslaught
  • 12
  • 9
  • 6
  • +1
29 Comments
 
LVL 52

Expert Comment

by:Joe Winograd, EE MVE
ID: 40587560
Two ideas:

(1) In the scheduled task, make sure the Run with highest privileges box is ticked.

Run elevated
(2) Fully qualify the command, that is:

c:\Windows\System32\shutdown.exe

Regards, Joe
0
 

Author Comment

by:jslaught
ID: 40588379
@ 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.
0
 
LVL 52

Accepted Solution

by:
Joe Winograd, EE MVE earned 500 total points
ID: 40588623
Is the Run only when user is logged on box ticked?

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?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 24

Expert Comment

by:NVIT
ID: 40588710
Just to verify...Is your task's Action set as...
Program: shutdown.exe
Add Arguments: /f /l
0
 

Author Comment

by:jslaught
ID: 40588729
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.
0
 

Author Comment

by:jslaught
ID: 40588744
@ 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.
0
 
LVL 52

Expert Comment

by:Joe Winograd, EE MVE
ID: 40588756
> 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
0
 

Author Comment

by:jslaught
ID: 40588777
@ 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.....
0
 
LVL 24

Expert Comment

by:NVIT
ID: 40588846
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
0
 
LVL 52

Expert Comment

by:Joe Winograd, EE MVE
ID: 40588868
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
0
 

Author Comment

by:jslaught
ID: 40589140
@ 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...
0
 
LVL 24

Expert Comment

by:NVIT
ID: 40589154
Have you tried other scheduled tasks? Do they run?
0
 

Author Comment

by:jslaught
ID: 40589155
@ 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.
0
 

Author Comment

by:jslaught
ID: 40589161
@ NewVillageIT

Yes we have other Task Scheduled Group Policies that automatically run successfully daily. Not sure why I can't get this to run.
0
 
LVL 52

Expert Comment

by:Joe Winograd, EE MVE
ID: 40589173
> 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
0
 
LVL 52

Expert Comment

by:Joe Winograd, EE MVE
ID: 40589177
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.
0
 

Author Comment

by:jslaught
ID: 40589187
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.
0
 
LVL 24

Expert Comment

by:NVIT
ID: 40589189
Try changing General, Change User or Group. Enter: System
0
 

Author Comment

by:jslaught
ID: 40589204
still getting the "0x1" last run result error for system user
0
 
LVL 24

Expert Comment

by:NVIT
ID: 40589226
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.
0
 
LVL 52

Expert Comment

by:Joe Winograd, EE MVE
ID: 40589230
> 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!
0
 

Author Comment

by:jslaught
ID: 40589259
@ NewVillageIT

tried your latest suggestion above and still getting the last run result of "0x1"
0
 

Author Comment

by:jslaught
ID: 40589983
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!
0
 
LVL 24

Expert Comment

by:NVIT
ID: 40590008
Glad you got it working, jslaught...
0
 
LVL 52

Expert Comment

by:Joe Winograd, EE MVE
ID: 40590049
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
0
 

Author Closing Comment

by:jslaught
ID: 40590817
Great suggestions from the experts. found the answer to my issue.
0
 

Expert Comment

by:ganesh kumar
ID: 41824065
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
0
 
LVL 52

Expert Comment

by:Joe Winograd, EE MVE
ID: 41824075
Hi ganesh,
I see that you joined EE today — welcome aboard! I suggest that you post a new question, which is likely to cause notifications to go to more experts. In your question, you may certainly have a link to this thread, and then augment it with additional information that is unique to your problem. Regards, Joe
0
 

Expert Comment

by:ganesh kumar
ID: 41824108
okay MR joe  thanks fro your prompt reply
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
This article explains how to install and use the NTBackup utility that comes with Windows Server.
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question