The best way to set the default printer via commandline, or in a batch
#1
Posted 03 August 2010 - 07:12 PM
rundll32 printui.dll,PrintUIEntry /y /q /n “Printer name”
also how can I disable UAC on the fly again via batch or command line?
#2
Posted 03 August 2010 - 08:54 PM
#3
Posted 03 August 2010 - 10:04 PM
cluberti, on 03 August 2010 - 08:54 PM, said:
#4
Posted 03 August 2010 - 10:52 PM
'---------------------------------------------------------------------- ' ' 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).
#5
Posted 04 August 2010 - 07:08 AM
cluberti, on 03 August 2010 - 10:52 PM, said:
'---------------------------------------------------------------------- ' ' 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.
This post has been edited by clivebuckwheat: 04 August 2010 - 07:10 AM
#6
Posted 04 August 2010 - 07:47 AM
reg ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f
However, 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 /f
In 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.
#7
Posted 04 August 2010 - 07:08 PM
here is the syntax I am using
cscript.exe "C:\Windows\System32\Printing_Admin_Scripts\en-US\Prnmngr.vbs" -t -p "http://myprintserver.qc.ca/ipps/2F16P"
I keep getting this error
C:\Windows\System32\Printing_Admin_Scripts\en-US\Prnmngr.vbs(818, 9) SWbemServic esEx: Not found
HELP!
cluberti, on 04 August 2010 - 07:47 AM, said:
reg ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f
However, 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 /f
In 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.
#8
Posted 04 August 2010 - 10:41 PM
#9
Posted 04 August 2010 - 11:39 PM
cluberti, on 04 August 2010 - 10:41 PM, said:
#10
Posted 05 August 2010 - 12:30 AM
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.DeviceID
Next
It's saying the object's DeviceID is not found - this is the line that's failing:
set oPrinter = oService.Get("Win32_Printer.DeviceID='" & strPrinter & "'")
#11
Posted 05 August 2010 - 06:48 AM
I will give it a shot.
cluberti, on 05 August 2010 - 12:30 AM, said:
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.DeviceID
Next
It's saying the object's DeviceID is not found - this is the line that's failing:
set oPrinter = oService.Get("Win32_Printer.DeviceID='" & strPrinter & "'")
#12
Posted 05 August 2010 - 02:40 PM
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.
clivebuckwheat, on 05 August 2010 - 06:48 AM, said:
I will give it a shot.
cluberti, on 05 August 2010 - 12:30 AM, said:
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.DeviceID
Next
It's saying the object's DeviceID is not found - this is the line that's failing:
set oPrinter = oService.Get("Win32_Printer.DeviceID='" & strPrinter & "'")
#13
Posted 05 August 2010 - 06:25 PM
#14
Posted 05 August 2010 - 10:37 PM
cluberti, on 05 August 2010 - 06:25 PM, said:
#15
Posted 06 August 2010 - 02:02 PM
- ← new user default settings
- Unattended Windows 7/Server 2008R2
- Is there such a command as reg del? →



Help
Back to top










