• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 727
  • Last Modified:

batch file scheduled task won't run

I have a batch file used to remove and remap shared network drives.
I've set up a scheduled task to run the script at 6pm daily and every hour for 23 hours.

The task is set to run with the domain user account credentials (which are a network admin and local admin), and the folder the batch file lives in (C:\scripts) and the batch file itself have FULL permissions for the same account.

The script runs by itself, but the scheduled task won't run....

What is going on?????
0
Reece Dodds
Asked:
Reece Dodds
  • 9
  • 5
  • 2
  • +1
3 Solutions
 
Computer-Service-St-LouisCommented:
Look inside eventviewer or the Task Scheduler and try to find the 0x0 code that winodws kicks out. This will tell you a lot. Post it here or google it and it should tell you exactly what the issue is. My guess would be that there is a parameter inside the scheduled task that may be triggered that prevents this from runnig, try creating a new task with the same batch file, and see if it runs, or edit the current task and have it run a different command. This will tell you if the issue is with the batch file or the scheduled task settings. Hope this helps!
0
 
Reece DoddsAuthor Commented:
screenshot
0
 
Reece DoddsAuthor Commented:
nothing shows in the even viewer under System or Application
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Reece DoddsAuthor Commented:
the SchedLgU.txt shows:  

"Logon(all).job" (Logon(all).bat)
      Started 28/10/2011 11:51:13 AM
"Logon(all).job" (Logon(all).bat)
      Finished 28/10/2011 11:51:13 AM
      Result: The task completed with an exit code of (1).
0
 
sjklein42Commented:
The batch file does appear to be running.  Please post the batch file itself, if you would like us to take a look at it.  Also, you may want to modify the batch file to log to a file so you can tell for sure whether or not it is being triggered:

time /t >> c:\mybatchfile.log
0
 
sjklein42Commented:
You could also log the output of your entire batch file by calling it from within another batch file, like this:

mybatch.bat:

time /t >c:\mybatchfile.log
call c:\mybatch2.bat >c:\mybatchfile.log  2>&1

Open in new window

and rename your old batch file to be mybatch2.bat

Note that the 2>&1 captures output to stderr (error messages).

This is a good idea anyway, in case you have problems in the future with this procedure.
0
 
ReneGeCommented:
I'd be glad to help.

I am a bit confused with this all.

You quote: (which are a network admin and local admin)
A local admin account have nothing to do with a network admin account (assuming you mean "network admin" = a "domain admin" account). Please confirm.

You quote: The script runs by itself, but the scheduled task won't run....
Won't run...? Task scheduler or your batch file"?

Like sjklein42 suggested, posting your batch file (by changing security infos), will help us a lot helping you.

Cheers,
Rene

0
 
Reece DoddsAuthor Commented:
this be my batch file:
 
@echo off

Net Use Z: /Delete /y
Net Use Z: \\192.168.1.252\Conveyancing /y

Net Use Y: /Delete /y
Net Use Y: \\192.168.1.252\Litigation1 /y

Net Use X: /Delete /y
Net Use X: \\192.168.1.252\Litigation2 /y

Net Use W: /Delete /y
Net Use W: \\192.168.1.252\Litigation3 /y

Net Use V: /Delete /y
Net Use V: \\192.168.1.252\Litigation4 /y

Net Use U: /Delete /y
Net Use U: \\192.168.1.252\Litigation5 /y

Net Use T: /Delete /y
Net Use T: \\192.168.1.252\Litigation6 /y

Net Use S: /Delete /y
Net Use S: \\192.168.1.252\MISC /y

Net Use R: /Delete /y
Net Use R: \\192.168.1.252\Admin /y

Net Use L: /Delete /y
Net Use L: \\192.168.1.252\Locus /y

Net Use I: /Delete /y
Net Use I: \\192.168.1.252\IT_ADMIN /y

Open in new window


By network admin I mean domain administrator credentials.
The scheduled task runs at the appointed times, and the script runs (when double-clicked), but the script doesn't run properly when called by the scheduled task... I can see the command prompt window appear for a second, then it disappears and the network drives aren't recreated.
0
 
ReneGeCommented:
-Maybe your running your task as a system account.
-Could you please look what account is setup, in scheduler, to run this task?
->Like suggestied be sjklein42, you could also add : >c:\mybatchfile.log  2>&1
at the end of your Task Scheduler command line. Then, share with us the content of: mybatchfile.log
0
 
Reece DoddsAuthor Commented:
I am using the domain account used to log on to this PC to run the scheduled task - not a local account.
I set up the log file and the output when run manually is this:  batlog.log

It initially came up with different result in the log file, so deleted the scheduled task and recreated it.
I think the issue was something to due with the timing schedule I had.  It is working now.

On another note...  Why does the command "shutdown -s -t 600" just repeat itself continuously with no action if placed in a batch file (so I can schedule a shutdown each night)???  
0
 
Reece DoddsAuthor Commented:
been off sick for the last week...

Any ideas how I can create a scheduled task the the shutdown -s command in a batch file?
see my above post.

cheers
0
 
ReneGeCommented:
You mean create a sched task to run a batch file, or to create the sched task by using a batch file?
0
 
Reece DoddsAuthor Commented:
Thanks for getting back to this problem ReneGe...

I can create the scheduled task to run a batch file.  I don't know how to use a batch file to create a scheduled task, but I don't think that's what I need here...
It's more that the shutdown.bat file I have doesn't work.  I must be missing something.

The command "shutdown -s -t 60" works fine using the command prompt, but when I save it into a batch file, it just loops.  If I could get this to work, I should then be able to create a scheduled task.
  looping script
0
 
ReneGeCommented:
The batch file name cannot be the same as of a command. Therefore, change your batchfile name to something else. Like: Sched_Shutdown.bat
0
 
Reece DoddsAuthor Commented:
OK, I did not know that...  So simple!    Why is that though???

Thanks dude.  Scheduled task works fine now.
0
 
ReneGeCommented:
Glad I could help :)
0
 
Reece DoddsAuthor Commented:
thanks again guys
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 9
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now