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
batch file question
I have a batch file to restart windows and want to do on a schedule. shutdown.exe /r /t 00 But when i try it manually or try to restart from start/restart there are programs running in the background and i have to force restart. What do i add to the batch file to stop the programs or force...
General Discussion
Newb, Win 7 Batch file question-KVM switching
hello Sorry if I'm posting this to the wrong place, but I'm not sure what this would be classed under. I would like to be able to change between the two computers connected to my KVM by clicking on an icon. My Belkin KVM has a remote switch that should be on my desktop, but my two cats...
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
Quick batch file question
Hi, I have just created a batch file to backup a few things on my machine, the thing is the batch file has a menu in it and i was wondering if i was to set the batch file to run under task scheduler say once a week is there a way i can get it to excute through the menu of the batch file? if not...
General Discussion
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 07:46.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App