Run works in bat file but NOT in scheduler

blockie

New member
Member
VIP
Local time
9:04 AM
Messages
605
Location
in Assisted Care facility, Calif
I have a batch file that removes files from a folder on a periodic basis. I created a task in the scheduler to have it run on a daily basis. I'm sure that all the parameters are correct. When I leave it up to the scheduler it fails with a 0x2331 error.
When I run the task from the batch file it runs OK.
When I try to run it from the scheduler it won't run. I have checked the path to the batch file time and again. I know its OK.
When I let the scheduler run normally it doesn't do the removal and returns an error of 0x2331.
I have checked and re-checked all settings. Even compared to an unrelated task that does work.
Any ideas?
Bill
 

My Computer My Computer

At a glance

W7 Ultimate2.2 bh Intel Core i3-2330M4MBOn Board
Computer type
Laptop
Computer Manufacturer/Model Number
Asus
OS
W7 Ultimate
CPU
2.2 bh Intel Core i3-2330M
Motherboard
Asustek Computer Inc. P53E 1.0
Memory
4MB
Graphics Card(s)
On Board
Sound Card
On Board
Monitor(s) Displays
On Board
Screen Resolution
1366 X 768
Hard Drives
ST9500423AS
ST2000DM USB Backup Drive External
A 0x2331 error usually means the program/command isn't recognised by the system.

Please upload the .bat file here and I'll take a look at it for you.
 

My Computer My Computer

At a glance

Windows 10 Pro x64 ; Xubuntu x64Intel i7 860 @ 2.80 GHz O/C'ed to 4.0GHz16GB Corsair Vengance DDR3 @ 661 MHz Dual Cha...EVGA NVidia GTX 560 1024MB
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Golden Mk. I.4
OS
Windows 10 Pro x64 ; Xubuntu x64
CPU
Intel i7 860 @ 2.80 GHz O/C'ed to 4.0GHz
Motherboard
Gigabyte P55A-UD3R Rev.1. Award BIOS F13
Memory
16GB Corsair Vengance DDR3 @ 661 MHz Dual Channel (9-9-9-24)
Graphics Card(s)
EVGA NVidia GTX 560 1024MB
Sound Card
Realtek Integrated
Monitor(s) Displays
Dual Samsung SyncMaster 2494HS
Screen Resolution
1920*1080 and 1920*1080
Hard Drives
1*Samsung 840 EVO 120GB SSD;
1*OCZ Vertex 2 60GB SSD;
2*Samsung F3 SpinPoint 1TB in RAID0;
1*Samsung F1 SpinPoint 1TB;
2*Western Digital 1TB External USB 3.0
1*Western Digital 500GB External USB 3.0
1*Seagate 500GB External USB 2.0
PSU
Thermaltake ToughPower QFan 750W
Case
Thermaltake Element S VK60001W2Z
Cooling
Corsair H60 Water Cooling, 2*230mm and 2*80mm case fans
Keyboard
Logitech G110
Mouse
Logitech MX518
Here it is and thanks for the help.
Bill
 

Attachments

My Computer My Computer

At a glance

W7 Ultimate2.2 bh Intel Core i3-2330M4MBOn Board
Computer type
Laptop
Computer Manufacturer/Model Number
Asus
OS
W7 Ultimate
CPU
2.2 bh Intel Core i3-2330M
Motherboard
Asustek Computer Inc. P53E 1.0
Memory
4MB
Graphics Card(s)
On Board
Sound Card
On Board
Monitor(s) Displays
On Board
Screen Resolution
1366 X 768
Hard Drives
ST9500423AS
ST2000DM USB Backup Drive External
Hi Blockie,

Specify the full path to this DELOLDER command.
E.g.
Code:
[COLOR="red"]"C:\Path\to\[/COLOR]DELOLDER[COLOR="Red"].exe"[/COLOR] cd/D D:\images\*.mrimg /Keep:4
 

My Computer My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Thanks Pyphrophly. Sorry Blockie....I completely forgot about this one.
 

My Computer My Computer

At a glance

Windows 10 Pro x64 ; Xubuntu x64Intel i7 860 @ 2.80 GHz O/C'ed to 4.0GHz16GB Corsair Vengance DDR3 @ 661 MHz Dual Cha...EVGA NVidia GTX 560 1024MB
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Golden Mk. I.4
OS
Windows 10 Pro x64 ; Xubuntu x64
CPU
Intel i7 860 @ 2.80 GHz O/C'ed to 4.0GHz
Motherboard
Gigabyte P55A-UD3R Rev.1. Award BIOS F13
Memory
16GB Corsair Vengance DDR3 @ 661 MHz Dual Channel (9-9-9-24)
Graphics Card(s)
EVGA NVidia GTX 560 1024MB
Sound Card
Realtek Integrated
Monitor(s) Displays
Dual Samsung SyncMaster 2494HS
Screen Resolution
1920*1080 and 1920*1080
Hard Drives
1*Samsung 840 EVO 120GB SSD;
1*OCZ Vertex 2 60GB SSD;
2*Samsung F3 SpinPoint 1TB in RAID0;
1*Samsung F1 SpinPoint 1TB;
2*Western Digital 1TB External USB 3.0
1*Western Digital 500GB External USB 3.0
1*Seagate 500GB External USB 2.0
PSU
Thermaltake ToughPower QFan 750W
Case
Thermaltake Element S VK60001W2Z
Cooling
Corsair H60 Water Cooling, 2*230mm and 2*80mm case fans
Keyboard
Logitech G110
Mouse
Logitech MX518
Both the batch file and Delolder.exe are in the same folder. I did it this way for convenience.
the path is" c:\\Users\owner\desktop\myscripts\delolder.exe"
Bill
 

My Computer My Computer

At a glance

W7 Ultimate2.2 bh Intel Core i3-2330M4MBOn Board
Computer type
Laptop
Computer Manufacturer/Model Number
Asus
OS
W7 Ultimate
CPU
2.2 bh Intel Core i3-2330M
Motherboard
Asustek Computer Inc. P53E 1.0
Memory
4MB
Graphics Card(s)
On Board
Sound Card
On Board
Monitor(s) Displays
On Board
Screen Resolution
1366 X 768
Hard Drives
ST9500423AS
ST2000DM USB Backup Drive External
Both the batch file and Delolder.exe are in the same folder.

There's your problem.

You should understand that when you specify the DELOLDER command in your script, you are relying on the Current Directory to be C:\Users\owner\desktop\myscripts.

One place CMD looks for commands is the current directory. When you execute a file through Explorer, the value of the current directory will be the path that your file resides in when you executed it. So DELOLDER.exe will reside in the current directory when you run your batch file through Explorer and your batch file is in the same folder as DELOLDER.exe.

When Task Scheduler runs a 'task', the current directory is not the path that the executable or script is found in.


Blockie, you've four options to fix your issue:

A) Specify the full path of the command in your script, e.g.,
Code:
[COLOR="Red"]"C:\Users\owner\Desktop\myscripts\[/COLOR]DELOLDER[COLOR="Red"].exe"[/COLOR] cd/D D:\images\*.mrimg /Keep:4

B) Place the DELOLDER.exe application in a directory mentioned in the %Path%

C) You many override default current directory Task Manager uses for your script by specifying a path for the "Start in (optional)" option in the Actions tab in Task Scheduler,

D) If you only have a single command in your batch file then there is no need for a batch file at all. Simply let Task Scheduler run the DELOLDER command directly.
 

My Computer My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
I took option "D" of your post and already am doing "C". Let the scheduler run DELOLDER.EXE with appropriate switches. Now get a 0X5 completion code (access denied).
I have checked the following,
Run whether I am logged in or not

If I double click DELOLDER.EXE there is a flash of the command prompt which tells me that it is doing something although no switches were used. So I am assuming that access is not denied doing this.
 

My Computer My Computer

At a glance

W7 Ultimate2.2 bh Intel Core i3-2330M4MBOn Board
Computer type
Laptop
Computer Manufacturer/Model Number
Asus
OS
W7 Ultimate
CPU
2.2 bh Intel Core i3-2330M
Motherboard
Asustek Computer Inc. P53E 1.0
Memory
4MB
Graphics Card(s)
On Board
Sound Card
On Board
Monitor(s) Displays
On Board
Screen Resolution
1366 X 768
Hard Drives
ST9500423AS
ST2000DM USB Backup Drive External
To help troubleshoot the issue, place the command back into a batch file and append the pause command as the last line of the batch file.

This will allow you to view the output of the command.
 

My Computer My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Boy! Do I have egg on my face. Did as you recommended. Returned a file not found. The bat file with pause revealed that I was trying to delete file in folder "image". Used to have that folder but during a disk rearrangement I moved the files in question up one level and then removed folder "image", but failed to update the batch file.
Works without error now.
Thanks,
Bill
 

My Computer My Computer

At a glance

W7 Ultimate2.2 bh Intel Core i3-2330M4MBOn Board
Computer type
Laptop
Computer Manufacturer/Model Number
Asus
OS
W7 Ultimate
CPU
2.2 bh Intel Core i3-2330M
Motherboard
Asustek Computer Inc. P53E 1.0
Memory
4MB
Graphics Card(s)
On Board
Sound Card
On Board
Monitor(s) Displays
On Board
Screen Resolution
1366 X 768
Hard Drives
ST9500423AS
ST2000DM USB Backup Drive External
Back
Top