Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Task Scheduling With Batch File Question

06 Nov 2013   #1
captainfearless

Windows 7 Ultimate x64
 
 
Task Scheduling With Batch File Question

Hi everyone,

I've recently been setting up some automation via TS with great success, until now.

I want it to delete daily all content, sub folders and files etc from my TV shows parent folder.

I am using the following shell script (.cmd batch file)

@echo off
setlocal enableextensions
if {%1}=={} goto :HELP
if {%1}=={/?} goto :HELP
goto :START

:HELP
echo Usage: %~n0 directory-name
echo.
echo Empties the contents of the specified directory,
echo WITHOUT CONFIRMATION. USE EXTREME CAUTION!
goto ONE

:START
pushd %1 || goto ONE
rd /q /s . 2> NUL
popd

ONE
endlocal


from this link Create Batch file to delete files and subfolders, but not root folder

I have it set up thus "C:\Scripts\CleanDir.cmd" \\Users\Administrator\Downloads\Deluge Completed in TS, and it has set everything after the commas as the argument.

It runs, it provides the result (0x1 the same as other tasks that do work), but nothing is deleted.

Can any more experienced user tell me what i'm doing wrong please? I'm guessing it's a comma or gap thing, something simple!


My System SpecsSystem Spec
.
06 Nov 2013   #2
Golden
Microsoft MVP

Windows 7 Ult. x64
 
 

Are you running the .BAT file with elevated (administrator) privileges?
My System SpecsSystem Spec
06 Nov 2013   #3
captainfearless

Windows 7 Ultimate x64
 
 

No! Only logged in as administrator with full power so that may be it , I'll try tonight thanks.
My System SpecsSystem Spec
.

06 Nov 2013   #4
captainfearless

Windows 7 Ultimate x64
 
 

Drat, this has not fixed it, restarted just to be sure.
My System SpecsSystem Spec
10 Nov 2013   #5
captainfearless

Windows 7 Ultimate x64
 
 

Sorted it using 3rd party software in the end.
My System SpecsSystem Spec
Reply

 Task Scheduling With Batch File Question




Thread Tools




Similar help and support threads
Thread Forum
Task Scheduler: Batch file stuck in 'running' status
I need to run a batch file using the System account when a user logs on. This is needed for Crashplan to see network drives, following the tip at The Crashplan Network Drive Workaround My batch file does the following: net use r: \\server\folder1 net use s: \\server\folder2 I have created...
Performance & Maintenance
batch&task to create new folder and move all desktop file to it
hi so work in an recruitment office and im trying to create a batch file that the computers can run on a schedule to create a folder with that days date on it and move all files from the desktop to that folder( also created on the desktop), i want the code to only move files and leave folders and...
General Discussion
Windows Task Scheduler Batch File
Hello: I have a Batch File, to move a file to a different folder, that I would like to run from Windows Task Scheduler on a windows server 2008 R2 . The batch file itself works, however running it from Windows Task Scheduler does not work. I am trying to move the file within the L drive. I...
General Discussion
Windows Task Scheduler stays active after it runned a batch file
Hi small question, My batch file runs quite well in windows task scheduler, but it stays active. How can I make sure Task Scheduler finishes this? I am closing VLC player with a command ending with --play-and-exit and then vlc:quit (to kill the processes in the task manager).
Performance & Maintenance
Task Scheduling
Im trying to automate most of the routine maintenance of my machine. I have ran into a few issues. What im trying to automate: CCleaner auto update CCleaner auto scan/delete CCleaner auto reg scan/fix Spybot auto update Spybot scan/remove/backup Defraggler auto update
Customization


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 17:45.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App