Running VSSADMIN command on Vista x64

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
bnc1
Pro Scripter
Posts: 127
Joined: Sun Jul 31, 2005 5:10 pm

Running VSSADMIN command on Vista x64

Post by bnc1 » Tue Oct 13, 2009 4:44 pm

I am trying to use Macro Scheduler Pro 11.1.15 to automate a daily run of the command VSSADMIN LIST SHADOWSTORAGE

This script works fine on a Vista x86 (32bit) system :

Code: Select all

let>RP_ADMIN=1
let>RP_WAIT=1
Run>"cmd.exe" /c vssadmin list shadowstorage  >> G:\doc\vss.txt
exit>0 
However when I run the same script on a Vista x64 system , I get error messages

Error: Unexpected failure: Catastrophic failure

If I manually start a command prompt window and enter the VSSADMIN command, it works just fine. Is there a way to get this script working on a x64 system ? Perhaps invoking a command prompt window from within Macro Scheduler (32bit) has some compatability problems with the VSSADMIN command (64bit) ???

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Oct 13, 2009 7:51 pm

Error: Unexpected failure: Catastrophic failure
Don't you love those highly descriptive and helpful messages? :roll:

Where are you seeing the error messages? are they ported to the vss.txt file?

I don't have the OSs to test it myself. Have you tried repacing the /c with a /k so the command window stays open. that way you can sometimes see error messages that otherwise go unseen.

Run>"cmd.exe" /k vssadmin list shadowstorage >> G:\doc\vss.txt

bnc1
Pro Scripter
Posts: 127
Joined: Sun Jul 31, 2005 5:10 pm

Post by bnc1 » Wed Oct 14, 2009 11:27 am

The VSSADMIN error messages are the same whether I use /c or /k with or without >>vss.txt port. The key issue appears to be running certain commands in a 64 bit OS. If I enter the commands manually they work fine. Its only when I use Macro Scheduler (which is a 32 bit program) that I have issues.

And to repeat, none of this is a problem on a 32 bit OS.

There are also show some strange errors in the application event log when using Macro Scheduler to run a CHKDSK command in a 64 bit OS. In this case the CHKDSK command does run successfully. However there are event ID errors 32 :

Volume Shadow Copy Service error: The VSS Coordinator class is not registered. This may be caused due to a setup failure or as a result of an application's installer or uninstaller.

and event ID errors 8193

Volume Shadow Copy Service error: Unexpected error calling routine CoCreateInstance. hr = 0x80040154.

These errors only show up when running CHKDSK via Macro Scheduler in a 64 bit OS. If I run the commands manually or in a 32 bit OS (manually or via MS) then there are no errors in the application event log. The CHKDSK scenario differs from VSSADMIN in that the command actually completes. :)

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Oct 14, 2009 1:17 pm

One of Macro Scheduler's strengths is that it can be a substitute for you. I can see where there might be a potential for a thread started by a 32 bit app to fail when trying to run a 64 bit app. I would think that there is a way to get past that if that is the issue. What I would try is to use Macro Scheduler as a typist. Either use it to open a command window or use it to get to Start > Run, then paste in the command that needs to be run. In other words avoid Macro Scheduler from being the thread starting application.

Code: Select all

Run>cmd
WaitWindowOpen>Cmd.exe*
Wait>0.5
SetFocus>Cmd.exe*
Send>dir c:\
Wait>0.5
Press Enter
Wait>0.5
Send>exit
Wait>0.5
Press Enter
OR

Code: Select all

Press LWinKey
Wait>0.5
Release LWinKey
send>r
Release LWinKey
Wait>0.5
Send>cmd.exe
Wait>0.5
Press Enter
WaitWindowOpen>Cmd.exe*
Wait>0.5
SetFocus>Cmd.exe*
Send>dir c:\
Wait>0.5
Press Enter
Wait>0.5
Send>exit
Wait>0.5
Press Enter

bnc1
Pro Scripter
Posts: 127
Joined: Sun Jul 31, 2005 5:10 pm

Post by bnc1 » Wed Oct 14, 2009 2:00 pm

I have already tried the technique you proposed but there is no change. Just to double check, I copied your script and tried it but there was no improvement :( :(

FYI ..I also tried this on Windows 7 X64 RC1 ..same problem but different error messages


Z:\Program Files (x86)\Macro Scheduler 11>vssadmin list shadowstorage
vssadmin 1.1 - Volume Shadow Copy Service administrative command-line tool
(C) Copyright 2001-2005 Microsoft Corp.

Error: A Volume Shadow Copy Service component encountered an unexpected error.
Check the Application event log for more information.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Oct 14, 2009 4:55 pm

A 64 bit version of Macro Scheduler is on the roadmap but will not be for another year or so (we are still waiting for a 64 bit compiler for the language we use which was expected this year but has been put back unfortunately).

In the mean time I found a workaround. The following will work if you have UAC disabled and run Macro Scheduler as Admin:

Code: Select all

Press LWinKey
Send>r
Release LWinKey
WaitWindowOpen>Run
Send>cmd.exe
Press Enter
WaitWindowOpen>cmd.exe*

SetFocus>cmd.exe*
Send>vssadmin list shadowstorage
Press Enter
This works because it opens the 64 bit version of cmd.exe in the same way a user would.

If you cannot have UAC disabled download this free tool called Elevate:
http://www.wintellect.com/CS/blogs/jrob ... vista.aspx

Then modify the above code to:

Code: Select all

Press LWinKey
Send>r
Release LWinKey
WaitWindowOpen>Run
Send>"%USERDOCUMENTS_DIR%\elevate.exe" cmd.exe
Press Enter
WaitWindowOpen>cmd.exe*

SetFocus>cmd.exe*
Send>vssadmin list shadowstorage
Press Enter
Of course you will have to manually OK the elevation prompt.

These work because they open cmd.exe as a user would open it from within the Operating System.

In both cases Macro Scheduler needs to be running as admin so that it can interact with the admin process. Or you could compile the script to a .exe and run that as admin.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

bnc1
Pro Scripter
Posts: 127
Joined: Sun Jul 31, 2005 5:10 pm

Post by bnc1 » Thu Oct 15, 2009 9:32 am

Thank you. :!: I had only tested JRL's first script. It looks like his second script also works by starting the cmd prompt without using the Run> command. I had to make changes to the script since it appears to work only with a classic start menu.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Nov 10, 2009 3:23 pm

Having revisited this I have found that the cause of this error is "File System Redirection". For example, the System32 folder is reserved for 64 bit applications (yes, despite the name) so if a 32 bit process tries to access that folder Windows redirects it elsewhere. Same goes with DLLs. In this case Macro Scheduler started the 32 bit version of cmd.exe, and vssadmin clearly needed access to the 64 bit sub system and wasn't getting it due to redirection.

See:
http://msdn.microsoft.com/en-us/library ... S.85).aspx

I have now discovered that an application can TURN OFF this redirection using the snappily titled Wow64DisableWow64FsRedirection function:
http://msdn.microsoft.com/en-us/library ... S.85).aspx

So, the more elegant solution to the original problem is now as follows:

Code: Select all

LibFunc>kernel32,Wow64DisableWow64FsRedirection,result,0

Let>RP_ADMIN=1
let>RP_WAIT=1
DeleteFile>%TEMP_DIR%\vss.txt
Run>"cmd.exe" /c vssadmin list shadowstorage  >> "%TEMP_DIR%\vss.txt"
ReadFile>%TEMP_DIR%\vss.txt,vss
MessageModal>vss

//make sure we revert redirection
LibFunc>kernel32,Wow64RevertWow64FsRedirection,result,0
Much nicer!

The above article recommends not redirecting for longer than necessary (you never know what some other app you may call will do) so always remember to revert with the Wow64RevertWow64FsRedirection function afterwards.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts