Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Afraid of executing a script on server

$
0
0

I have to make a script which deletes all the folders and files in the following directories on Windows Server 2008:

D:\frotxy\out\backup\

D:\frotxy\in\backup\

Yesterday I tried executing the script from my Desktop to delete the files in a test folder but unfortunately I had mistaken the path to this folder. What happened was my Desktop files were deleted - ARGHH! 

So my question is is there a safer way to do the script and check it before executing it on the server as it is important not to delete some other directory or file from the server :)

This is the script:

set folder="D:\frotxy\out\backup"
cd /d %folder%
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)

set folder="D:\frotxy\in\backup"
cd /d %folder%
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)

And where should I place the file containing the script?

I am not into scripts at all so please help!


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>