Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.




1748 posts

Uber Geek
+1 received by user: 361

Trusted

Topic # 66449 19-Aug-2010 10:58
Send private message

I'm having a hell of a job getting a script to run under Server 2008 R2. It's simple enough, works under all other recent versions of MS Windows - XP, Server 2003, Win 7, Server 2008.

It started off with a cmd line PRINTUI entry to capture default settings of printers, viz:

RUNDLL32 PRINTUI.DLL,PrintUIEntry /Ss /n <printer> /a c:\printer.bin

then to restore:


RUNDLL32 PRINTUI.DLL,PrintUIEntry /Sr /n <printer> /a c:\printer.bin g d u

where <printer> is the name of the printer

These 2 command line functions work well in all recent versions of MS Windows, except Server 2008 R2. On Server 2008 R2, I get an error code 0000000c. Tested on two different installations of Server 2008 R2, so it's not just my setup.

A look into technet mentioned that any cmd line functions should now be scripted. Being a complete noob @ scripting, a colleague wrote a Q&D script:

set wshell = CreateObject("WScript.Shell")
    wshell.run "RUNDLL32 PRINTUI.DLL,PrintUIEntry /Sr /n PRINTER /a c:\printer.bin g d u", 0, TRUE
    set wshell = nothing

msgbox "OK"

Again, this script does not work on Server 2008 R2, not even the expected OK dialog box. No error codes, nada. Script works OK on any previous Windows versions.

What the heck am I doing wrong ?








My thoughts are no longer my own and is probably representative of our media-controlled government


Create new topic


1748 posts

Uber Geek
+1 received by user: 361

Trusted

  Reply # 369773 19-Aug-2010 12:46
Send private message

More playing around:
On Server 2008 R2, I can use the command line:
RUNDLL32 PRINTUI.DLL,PrintUIEntry /Ss /n /a c:\printer.bin
to create the restore file, printer.bin. Works.

Copied this printer.bin file to Server 2008 (STD), and ran the restore command from the cmd prompt:
RUNDLL32 PRINTUI.DLL,PrintUIEntry /Sr /n /a c:\printer.bin g d u

Printer settings restored. So the restore file is not corrupt, and can be created from the command line on Server 2008 R2.

So it's ony on Server2008 R2 that this restore command is not working - I'm beginning to think this is some kind of permissions thing ?




My thoughts are no longer my own and is probably representative of our media-controlled government


217 posts

Master Geek
+1 received by user: 2


  Reply # 369804 19-Aug-2010 14:08
Send private message

Error 0x0000000c translates as "The access code is invalid" - not much help really, but it suggests it may not be an explicit permissions issue, or you'd have got 0x00000005.

When they say this sort of stuff should be scripted, they're talking about using VBscript or Jscript to access a COM object to perform the actions. Having a script fire off a command via WshShell.Run isn't any different to running it yourself from the command prompt.

There are plenty of VBscript code fragments on the net; you may be able to find one to use without first having to learn too much scripting.

Create new topic



Twitter »

Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.


Geekzone Live »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.