Search The Web

Thursday, September 29, 2011

remove network printers from command line or script


remove network printers from command line or script



There are several options when it comes to removing printers via command line / script.The first option is to use the "rundll32 printui.dll" method. For this, open a command prompt and type:

rundll32 printui.dll,PrintUIEntry /dn /n \\printsvr\printername

if you want the operation to be silent, then use the /q switch at the end. this is especially useful if you have multiple printers that you want to remove via a batch file and/or if you are unsure if the printers are installed on the end users machines. If the printer is not currently installed and you attempt to remove it without the /q switch then you will receive an error. The figure below shows the command in its entirety:

The next method would be to use a VB script such as this :
to make the script work, just replace the \\PRINTSERVER\PRINTERNAME" field with the details of your network printer and save as a .vbs file. to call the script just open up an administrator command prompt and type in " cscript scriptname.vbs " where scriptname is the name of your script.
To delete more printers just another line to the  " Dim sPrinterName "  lines with the printer number at the end, and then again  add another objNetwork.RemovePrinterConnection sPrinterName2, True, True line that reflects the printer number you just added.
Likewise, to remove only one printer just remove one of the above lines.


Option Explicit

  Dim objNetwork, objPrinters

  Set objNetwork = CreateObject("WScript.Network")
  Set objPrinters = objNetwork.EnumPrinterConnections

  ' ### Delete selected network printer

  Dim sPrinterName1
 Dim sPrinterName2
  sPrinterName1 = "\\PRINTSERVER\PRINTERNAME"
 sPrinterName2 = "\\PRINTSERVER\PRINTERNAME"
  objNetwork.RemovePrinterConnection sPrinterName1, True, True
 objNetwork.RemovePrinterConnection sPrinterName2, True, True

I found with this method however that it will error out if that printer does not exist. im not enough of a VB guru to tell you if its possible to quieten it down to run silently.

When all is said and done, there is a much better way of doing this, and that is with Group Policy Preferences. this gives you centralized control over your printer environments, allowing you to add and remove and update printers for small groups or your entire organisation.
Group Policy Preferences will be covered for printers in an upcoming entry.

Thursday, September 22, 2011

how do i add domain users as local admins?

how do i add domain users as local admins?


In environments where you must have local admin access (yes, this is far from ideal but we can get to that later) its not a good idea to add domin users to local admins unless you like you users to have admin rights over each others machines. this can be especially fun in a school / college environment!

a better way to manage this is to have the logged in user on the machine (aka interactive account) become a local admin for its logged in tenure.

the command to do so is (from a dos prompt or batch file):

net localgroup Administrators interactive /add










once again, its far better to avoid local admin access, but if you have to use it, this is the best way i have found to manage it


Tuesday, September 6, 2011

how do i add a network printer for all users?


use this for making printers install for all users instead of the current user in Windows 7

To install the printer for all users, follow these steps:
1. Click Start, click Control Panel and double click Devices and Printers.
2. Click Add a Printer.
3. Select "Add a local printer".
4. Select "Create a new port". Choose "Local Port" as the type of the port.

5. In the box "Enter a port name", type the address as the following format.
\\ [IP address of the host computer]\[The Share Name of the printer]
Then click Next.
6. Choose the correct driver in the driver list. If no available driver, click the button Windows Update, wait for the process finishes and then look for the driver again.
7. Shared this printer to all the users.
8. Finish the installation.

How do I old out a Windows 7 User profile?

“Old-ing” out user profiles is a little different in Windows 7 as discovered recently. This is procedure I found on the interweb and should be followed in place of XP style method
Move C:\Users\%username% to another folder e.g. c:\temp

Delete C:\Users\TEMP to another folder e.g. c:\temp

Delete the
registry key matching the users SID from
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\ProfileList". Check the value "ProfileImagePath" to make sure you
Pick the correct profile.

Restart once again and then you're done.

How do i un-install Windows software remotely?

a couple of ways to uninstall windows programs other than add remove programs. mainly used for silent and unattended uninstalls.

WMIC

  • use "wmic product get name" to find the exact installed name of the product
  • to uninstall type "wmic product where name ="" call uninstall
Registry

  • Open Regedit
  • find HKLM\software\microsoft\windows\current version\uninstall
  • this will list the string for uninstalling the product in verbose mode normally.
  • to find the silent install locate the exe as listed and query it with a \? swtich to find the silent install option ( more often than not it is /S)