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

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

Microsoft Community Contributor Award Recipient

Windows 7 Ult. x64 Windows 8.1 x64 Ubuntu 12.04 LTS Tri-Boot
 
 

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

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

Windows 7 Ultimate x64
 
 

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

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 for2: Task Scheduling With Batch File Question
Thread Forum
Windows Task Scheduler stays active after it runned a batch file Performance & Maintenance
Quick batch file question General Discussion
need help scheduling a task, Please Performance & Maintenance
Task Scheduling Customization
question in batch (bat) file General Discussion

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 06:25 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33