cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
hogwell
Level 3

Adding a Printer using a Custom Action on Windows 7 - Access Denied

I am having an issue with a Custom Action that Adds a Printer.

The CA calls cscript to run the standard prnmngr.vbs script to do this.

The CA is scheduled to run Deferred in System Context.

The problem is that the installation works fine on Vista 32-bit (UAC disabled) and adds the printer to the system properly.

On Windows 7 64-bit however, the VBscript runs, but fails with a 0x80041003 Access Denied error and is unable to add the printer.

Googling this error code indicates that it is caused by insufficient permissions to invoke WMI to add the printer.

My Basic MSI release is set up to require Administrator priviledges, but I suspect that Windows Installer 4.5 is not running cscript "As Administrator" so it is unable to add the printer.

I suspect this because running the cscript command to add the printer from an Administrator command prompt window works fine on this Windows 7 machine.

The strange thing is that if I add the printer manually, my Uninstall is able to remove the printer just fine by running a similar deferred cscript custom action!

What's going on here? Has anybody seen this before?

Is there a way to deal with this for Windows 7 installations?
Labels (1)
0 Kudos
(3) Replies
Not applicable

Run 64-bit VBScripts code or 32-bit VBScripts code?
0 Kudos
hogwell
Level 3

The CA runs c:\windows\sysWOW64\cscript.exe to run the script file.

My understanding is that the CA should be running in an elevated sandbox, which should behave the same as when I run the same script from a Run As Administrator Command Prompt.

Why do the WMI calls fail from the msi but they work from the command prompt?
0 Kudos
hogwell
Level 3

I have been unable to determine why my elevated custom action does not have the necessary permissions to create a printer using prnmngr.vbs.

Since I use a similar CA to delete a printer during uninstall, which works, I have to assume that this is a bug in Windows 7 and/or Windows Installer 4.5.

Meanwhile, I've resorted to running the same script to add a printer as an Installshield prerequisite to get around this problem.
This works.

I still would love to find out why this can't work from an elevated MSI CA.
(I guess Windows Installer doesn't "elevate" permissions enough.)
0 Kudos