Earlier  I made setup project in VS2008 to build msi which installs printer and that worked in WinXP and Vista.

But now the same MSI is not working in Windows7.

 

MSI setup project basically was made of VBS script which was executed on Custom Action – Install.

This is part of script that added printer:

 

Dim DRIVER

Dim PRINTERnAME

 

DRIVER="HP LaserJet 2300 Series PS"

PORT="C:\ProgramData\Application Data\xy\xy.ps"

PRINTERnAME="PrinterXY"

 

Dim objPrinter

Dim objWMIService

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True

 

Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_

objPrinter.DriverName = DRIVER

objPrinter.PortName   = PORT

objPrinter.DeviceID   = PRINTERnAME

objPrinter.Put_

 

Set objPrinter = Nothing

Set objWMIService = Nothing

 

In rest of script I added folder and wrote registry key to add port, after that printer service was restarted.

The problem is that under win7 all other steps of script are executed successfully but the part when printer is added fails.

Previously on vista that worked, no problem as long as MSI (setup.exe ) was run “as administrator”.

Also if I run same VBS script used in MSI, under win7, using “run as administrator”, script is executed successfully and printer is installed.

If I understand correctly VS2008 is already setting flag for no impersonation, so there is no need for changing that in MSI, which may cause not to execute script under admin rights.

I also tried without :{impersonationLevel=impersonate}! In script, but that made no difference.

Does anybody know what should be set in MSI properties or VBS script to work under win7.