How to get   vssadmin delete shadows /all to run in a batch file

donpick
donpick used Ask the Experts™
on
Running Small Business Server 2008 on a HP ML350 G5 server.
The 3rd party backup fails often with the error:  “Failed to Create Volume Snapshot.  Result code :  0x0042313”

I have found if I execute the command:
  vssadmin delete shadows /all

This command will fix the problem.  

Question:  I'd like to run this as a batch file.  The batch file will execute the   vssadmin delete shadows /all
   command.  The   vssadmin command asks a question when it executes.  In my batch file I placed the letter Y under the command to run   vssadmin .   It seems   vssadmin does not see the Y  so it just sits there waiting for something to enter the letter Y.

I am not a script expert.  What script would you suggest I write so the   vssadmin delete shadows /all   will see the letter Y and run to completion?

Thank you for your help.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
Didn't try if it works with vssadmin, but usually you just write
   echo y| vssadmin delete shadows /all
Or vssadmin delete shadows /all << Y should feed the Y answer to the command.
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
Nope, Davis, there is no << in Windows.
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

Author

Commented:
Hello Qlemo:
  The command you suggest does not work.
The error message is "invalid command"
Then a list of "Commands Supported" follows

Is there a way to do this with vbscript or something else?
Solutions Architect
Commented:
vssadmin delete shadows /all /quiet
C:\Windows\system32> echo Y | vssadmin delete shadows /all
vssadmin 1.1 - Volume Shadow Copy Service administrative command-line tool
(C) Copyright 2001-2005 Microsoft Corp.

Do you really want to delete 42 shadow copies (Y/N): [N]? Error: Unexpected failure: The handle is invalid.

C:\Windows\system32>vssadmin delete shadows /all /quiet
vssadmin 1.1 - Volume Shadow Copy Service administrative command-line tool
(C) Copyright 2001-2005 Microsoft Corp.

C:\Windows\system32>vssadmin list shadows
vssadmin 1.1 - Volume Shadow Copy Service administrative command-line tool
(C) Copyright 2001-2005 Microsoft Corp.

No items found that satisfy the query.

C:\Windows\system32>

Open in new window

Did you run the file as an administrator?

I wish you had run the list option to show the shadow copies as still there before you deleted them.
jrhelgesonSolutions Architect

Commented:
I figured the fact it showed "Do you really want to delete 42 shadow copies (Y/N)" shows that there were 42 shadow copies prior to deleting them.  I figured that was sufficient rather than showing lots of irrelevant information.

Author

Commented:
Hello jrhelgeson

Excellent work!   Your solution works.  This is great, I don't have to do this manually anymore.

Hello DavisMcCarn:  Yes, I created a batch file with the commands specified by  jrhelgeson .  I opened a Command window having administrative privileges .  I ran  jrhelgeson command and it works.

So now I will schedule the execution of  the batch file and have it log in as adminstrator.

Thanks again for helping me.  I pay to use Experts – Exchange so prompt and correct answers are greatly appreciated.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial