By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,143 Members | 1,919 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,143 IT Pros & Developers. It's quick & easy.

Batch file wont start service after DELTREE call

P: 384
I have a batch file and all it does is stop a service call the deltree file to empty a directory and the start the service but its wont start the service back up.

The first two lines run a fine, service stops, specified directory is emptied out and it ends with no errors and the service hasn't been started.

Any ideas/help much appreciated.

Expand|Select|Wrap|Line Numbers
  1. NET STOP "service_name"
  2. DELTREE "C:\temp\"
  3. NET START "service_name"
Expand|Select|Wrap|Line Numbers
  1. @echo off
  2. if {%1}=={} @echo Syntax: DelTree Folder&goto :EOF
  3. if not exist %1 @echo Syntax: DelTree Folder - Folder %1 does not exist.&goto :EOF
  4. pushd %1
  5. if %ERRORLEVEL% NEQ 0 @echo Syntax: DelTree Folder - Folder %1 does not exist.&goto :EOF
  6. del /q /f "*.*"
  7. for /f "Tokens=*" %%i in ('dir %1 /B /A /AD') do rd /s /q "%%i"
  8. popd
Jul 6 '10 #1
Share this Question
Share on Google+
1 Reply

P: 4
Maybe calling NET START while the service is stopping. Try adding a 5 second delay before calling NET START.
Jul 26 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.