Create a Printer Port from the Command Line using VB Script

To create a printer port using the command line you can use a microsoft utility found in the c:\Windows\System32 folder on Windows XP/2003 systems called prnport.vbs.

Using this VBScript makes it easy to add multiple printer ports for a new system or to migrate to a new port range for an existing server.

Open up a command prompt and cd to c:\windows\system32 then type the below command:

cscript prnport.vbs -a -r IP_10.0.0.254 -h 10.0.0.254 -o  raw -n 9100 -me

This will a Raw IP printer port with the Address 10.0.0.254 with the port number 9100, it will also enable SNMP.

If you putting the above command within a DOS FOR loop you can create a tonne of ports in a few seconds. An Example is below:

for %i in (254,253,252,251,249,248,247,245,244,243,242,241) do cscript prnport.vbs -a -r IP_10.0.0.%i -h 10.0.0.%i -o raw -n 9100 -me

This will create the ports 10.0.0.241 through to 10.0.0.254

More info on this command using the help found in the VBScript file itself.:

C:\WINDOWS\system32>cscript.exe prnport.vbs /?
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

Usage: prnport [-adlgt?] [-r port][-s server][-u user name][-w password]
[-o raw|lpr][-h host address][-q queue][-n number]
[-me | -md ][-i SNMP index][-y community][-2e | -2d]
Arguments:
-a     – add a port
-d     – delete the specified port
-g     – get configuration for a TCP port
-h     – IP address of the device
-i     – SNMP index, if SNMP is enabled
-l     – list all TCP ports
-m     – SNMP type. [e] enable, [d] disable
-n     – port number, applies to TCP RAW ports
-o     – port type, raw or lpr
-q     – queue name, applies to TCP LPR ports
-r     – port name
-s     – server name
-t     – set configuration for a TCP port
-u     – user name
-w     – password
-y     – community name, if SNMP is enabled
-2     – double spool, applies to TCP LPR ports. [e] enable, [d] disable
-?     – display command usage

Examples:
prnport -l -s server
prnport -d -s server -r IP_1.2.3.4
prnport -a -s server -r IP_1.2.3.4 -h 1.2.3.4 -o raw -n 9100
prnport -t -s server -r IP_1.2.3.4 -me -y public -i 1 -n 9100
prnport -g -s server -r IP_1.2.3.4
prnport -a -r IP_1.2.3.4 -h 1.2.3.4

Remark:
The last example will try to get the device settings at the specified IP address.
If a device is detected, then a TCP port is added with the preferred settings for that device.

  • Share/Bookmark

Help Protect Your Kids Online Free Using OpenDNS

As a new father I’ve been having a think about how to help protect our home network from malicious websites, adult websites, phishing websites and other nasties like sites that condone drugs and alcohol.

One easy way to do this is to use an internet service called OpenDNS. When enabled on your network OpenDNS will handle all your requests for a webpage. eg. when you type in www.internetbadguys.com into your browser your computer or router will first ask OpenDNS if that webpage is alright to visit or not. If its on the blocked list you will get a message similar to the below warning.

opendns1

To get started go to http://www.opendns.com and sign up for their free account. (You can use their DNS Servers without signing up for an account but it doesn’t do any blocking).

Once your logged in you can add your network to the Network Tab  (it should automatically detect your IP Address). Next under the Settings tab you can select the level of protection you would like by selecting High, Moderate, Low or Custom. There are other settings you can chose but those two settings are the bare minimum you will need to configure on their website.

The next step is to setup your network to use OpenDNS by either adding the DNS settings to your router or to your computer. Fortunately they have a really good writeup of now to do this at https://www.opendns.com/start

Once thats done check to see if you’ve set things up properly by going to www.internetbadguys.com. If you have you will get to the following screen in your browser.

opendns2

  • Share/Bookmark

Find and Delete Inactive Computer Accounts on a Domain

To find the inactive computer accounts of 25 weeks or more run the following command in a command prompt on your domain controller:

dsquery computer domainroot -d DOMAINNAME -inactive 25 >c:\inactive25.txt

To delete the inactive computers run the following command in a command prompt on your domain controller:

for /F %i in (‘dsquery computer domainroot -d DOMAINNAME -inactive 25′) do @dsrm %i -noprompt

Replace DOMAINNAME with the domain name of your organisation and substitute 25 with the specific number of weeks you want to check for.

  • Share/Bookmark