The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,831 other followers

Circumventing error 80070006 when running VBS (in this case: DBRESTORE.VBS to backup/restore your Windows XP Embedded Database): wscript versus cscript

Posted by jpluimers on 2009/07/10

At a client, I had to backup their Windows XP Embedded Database using DBRESTORE.VBS.
You can find more about that tool in DBRestore Command Line Syntax.

Error 80070006 during dbrestore.vbs execution

Error 80070006 during dbrestore.vbs execution

This tool is supposed to be run from the command-line, but the first thing I got was an error 80070006.
Since I the client was running a Dutch Windows system, the error would manifest itself as this:

---------------------------
Windows Script Host
---------------------------
Script:	C:\temp\ValueAdd\dbrestore.vbs
Regel:	72
Teken:	2
Fout:	De ingang is ongeldig.
Code:	80070006
Bron: 	(null)
---------------------------
OK
---------------------------

Although I’m not a VBS programmer, I know how to read source code in various languages, so below is how I solved the issue.

You can run Windows Scripting Host in debug mode using these switches:

C:\temp\ValueAdd>wscript //d dbrestore.vbs

The problem was around these lines of code, manifesting itself on the ‘WriteLine’ call:

Option Explicit

Dim g_oStdOut : Set g_oStdOut = WScript.StdOut

Sub WLF(text)
	g_oStdOut.WriteLine text     ' this was line 72
End Sub

Luckily, Microsoft has a long list of these kinds of error codes on their site.
The English translation of error 80070006 is “Invalid handle.”.
So apparantly, Windows Scripting Host does not have StdOut.

This technet post taught me there are two kinds of scripting hosts: wscript.exe and cscript.exe
They both can execute .VBS files, but cscript is bound to the console, and wscript is detached from the console.

And since on this machine .VBS files were bound to wscript.exe in stead of cscript.exe, I got the error message.

The final solution was simple:

C:\temp\ValueAdd>cscript dbrestore.vbs MACHINE_NAME c:\temp\XP-Embedded-backup /CB

Now the client has backups…

–jeroen

Edit: Duh – somehow I missed this post on my first search round: Backing Up and Restoring Your XP Embedded Database – the comments there clearly explain the 80070006 :-)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: