clivebuckwheat Posted August 4, 2010 Posted August 4, 2010 Is this still valid?rundll32 printui.dll,PrintUIEntry /y /q /n “Printer name”also how can I disable UAC on the fly again via batch or command line?
cluberti Posted August 4, 2010 Posted August 4, 2010 If you're using Vista or Win7, look in the \System32 folder for the Printing_Admin_Scripts folder. There are vbs scripts there to do printer management, so you no longer have to use rundll32 to install drivers, queues, etc.
clivebuckwheat Posted August 4, 2010 Author Posted August 4, 2010 The printers are already installed, I just have to set the right default printer. Hopefully this scripts can do it. If you're using Vista or Win7, look in the \System32 folder for the Printing_Admin_Scripts folder. There are vbs scripts there to do printer management, so you no longer have to use rundll32 to install drivers, queues, etc.
cluberti Posted August 4, 2010 Posted August 4, 2010 From prnmngr.vbs:'----------------------------------------------------------------------'' Copyright (c) Microsoft Corporation. All rights reserved.'' Abstract:' prnmngr.vbs - printer script for WMI on Windows ' used to add, delete, and list printers and connections' also for getting and setting the default printer'' Usage:' prnmngr [-adxgtl?][co] [-s server][-p printer][-m driver model][-r port]' [-u user name][-w password]'' Examples:' prnmngr -a -p "printer" -m "driver" -r "lpt1:"' prnmngr -d -p "printer" -s server' prnmngr -ac -p "\\server\printer"' prnmngr -d -p "\\server\printer"' prnmngr -x -s server' prnmngr -l -s server' prnmngr -g' prnmngr -t -p "printer"''----------------------------------------------------------------------You would use -t -p "printer" to set the default printer by it's common name (use -g to get the current default to see what I mean).
clivebuckwheat Posted August 4, 2010 Author Posted August 4, 2010 (edited) From prnmngr.vbs:'----------------------------------------------------------------------'' Copyright (c) Microsoft Corporation. All rights reserved.'' Abstract:' prnmngr.vbs - printer script for WMI on Windows ' used to add, delete, and list printers and connections' also for getting and setting the default printer'' Usage:' prnmngr [-adxgtl?][co] [-s server][-p printer][-m driver model][-r port]' [-u user name][-w password]'' Examples:' prnmngr -a -p "printer" -m "driver" -r "lpt1:"' prnmngr -d -p "printer" -s server' prnmngr -ac -p "\\server\printer"' prnmngr -d -p "\\server\printer"' prnmngr -x -s server' prnmngr -l -s server' prnmngr -g' prnmngr -t -p "printer"''----------------------------------------------------------------------You would use -t -p "printer" to set the default printer by it's common name (use -g to get the current default to see what I mean).Thank you sir,I have learned so much from this place. would you know how to turn off uac it is bothersome. Edited August 4, 2010 by clivebuckwheat
cluberti Posted August 4, 2010 Posted August 4, 2010 If it's just for your own machine, you can modify the EnableLUA reg value via the command:reg ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /fHowever, if this is in any sort of domain environment (where UAC for non-admin users is actually preferable), you can make a local (or group) policy change so that Admins don't get prompted under Computer Configuration > Windows Settings > Local Policies > Security Options > User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode - set this to "Elevate without prompting". Note that this can also be done by direct modification of the ConsentPromptBehaviorAdmin reg value via the command:reg ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /fIn a domain environment you would want to do this from a policy rather than a registry tatoo, but it is possible to edit the registry to mimick this policy.
clivebuckwheat Posted August 5, 2010 Author Posted August 5, 2010 I am trying to use the vbs scripts built into Windows 7 you pointed me to.here is the syntax I am usingcscript.exe "C:\Windows\System32\Printing_Admin_Scripts\en-US\Prnmngr.vbs" -t -p "http://myprintserver.qc.ca/ipps/2F16P"I keep getting this errorC:\Windows\System32\Printing_Admin_Scripts\en-US\Prnmngr.vbs(818, 9) SWbemServic esEx: Not foundHELP!If it's just for your own machine, you can modify the EnableLUA reg value via the command:reg ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /fHowever, if this is in any sort of domain environment (where UAC for non-admin users is actually preferable), you can make a local (or group) policy change so that Admins don't get prompted under Computer Configuration > Windows Settings > Local Policies > Security Options > User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode - set this to "Elevate without prompting". Note that this can also be done by direct modification of the ConsentPromptBehaviorAdmin reg value via the command:reg ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /fIn a domain environment you would want to do this from a policy rather than a registry tatoo, but it is possible to edit the registry to mimick this policy.
cluberti Posted August 5, 2010 Posted August 5, 2010 That printer name looks awfully wrong - I think you're trying to set a default printer with a connection you haven't created. Look deeper into the -ac and -p options (run the script with no switches to get an idea of what you're doing wrong).
clivebuckwheat Posted August 5, 2010 Author Posted August 5, 2010 The connection does exists in ports under printers. I am looking at it as I type this.That printer name looks awfully wrong - I think you're trying to set a default printer with a connection you haven't created. Look deeper into the -ac and -p options (run the script with no switches to get an idea of what you're doing wrong).
cluberti Posted August 5, 2010 Posted August 5, 2010 Is that an actual printer name though? Try running this as a .vbs, and see what deviceIDs you have on that box (again, assuming that port and printer is already added):strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_Printer",,48) For Each objItem in colItems Wscript.Echo "-----------------------------------" Wscript.Echo "Win32_Printer instance" Wscript.Echo "-----------------------------------" Wscript.Echo "DeviceID: " & objItem.DeviceIDNextIt's saying the object's DeviceID is not found - this is the line that's failing:set oPrinter = oService.Get("Win32_Printer.DeviceID='" & strPrinter & "'")
clivebuckwheat Posted August 5, 2010 Author Posted August 5, 2010 The printer looks wrong because it's Novell using ipp printing,I will give it a shot.Is that an actual printer name though? Try running this as a .vbs, and see what deviceIDs you have on that box (again, assuming that port and printer is already added):strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_Printer",,48) For Each objItem in colItems Wscript.Echo "-----------------------------------" Wscript.Echo "Win32_Printer instance" Wscript.Echo "-----------------------------------" Wscript.Echo "DeviceID: " & objItem.DeviceIDNextIt's saying the object's DeviceID is not found - this is the line that's failing:set oPrinter = oService.Get("Win32_Printer.DeviceID='" & strPrinter & "'")
clivebuckwheat Posted August 5, 2010 Author Posted August 5, 2010 Cluberti, thanks man that script gave me the proper path name of the printer. The default printer, and a printer deletion works now.Is there a way to run a cmd file with elevated privileges or as administrator?. I am running a cmd file from a login script.The printer looks wrong because it's Novell using ipp printing,I will give it a shot.Is that an actual printer name though? Try running this as a .vbs, and see what deviceIDs you have on that box (again, assuming that port and printer is already added):strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_Printer",,48) For Each objItem in colItems Wscript.Echo "-----------------------------------" Wscript.Echo "Win32_Printer instance" Wscript.Echo "-----------------------------------" Wscript.Echo "DeviceID: " & objItem.DeviceIDNextIt's saying the object's DeviceID is not found - this is the line that's failing:set oPrinter = oService.Get("Win32_Printer.DeviceID='" & strPrinter & "'")
cluberti Posted August 6, 2010 Posted August 6, 2010 The runas command should be able to do this, although if the user is not an administrator they'll likely see a consent prompt unless you change the default behavior in policy.
clivebuckwheat Posted August 6, 2010 Author Posted August 6, 2010 I found a work around, is there a way to turn of the windows scripting confirmation box, on the fly?The runas command should be able to do this, although if the user is not an administrator they'll likely see a consent prompt unless you change the default behavior in policy.
cluberti Posted August 6, 2010 Posted August 6, 2010 Are you talking about the UAC prompt dialog? If so, the answer is no (imagine the security hole if you could dismiss the box from script..... ).
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now