Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Help re-writing kix script to vbs? Maps printers...


Recommended Posts

Posted

Hi clever, dark-art-of-scripting folks.

 

Need to re-write a kix script in vbs, which maps printers for certain PCs in an interesting way.

 

Each PC has a .pnt file (text file) in the netlogon\setprinters folder. The kix script searches the setprinters folder for the .pnt file which corresponds to the machine name, and maps printers accordingly.

 

The script itself is:

 

;CHECK FOR ADDITIONAL PRINTERS
if open (1, "%LOGONSERVER%\netlogon\printers\" + @hostname + ".pnt", 2) = 0
$newfline = ReadLine(1)
$findex = 0
$lineno = 20
while @error = 0
	$pntarray = split($newfline, "=")
	if $pntarray[$findex] = "printer"
		$findex = $findex + 1
		$ERRH = AddPrinterConnection ($pntarray[$findex])
		; Added by Bruce for DEBUG: 2006-09-07
		if @Userid = "denise"
			AT ($lineno,5) "Adding printer: " + $pntarray[$findex]
			$lineno = $lineno + 1
		endif
	else
		$findex = $findex + 1
		$ERRH = SetDefaultPrinter ($pntarray[$findex])
		; Added by Bruce for DEBUG: 2006-09-07
		; AT ($lineno,5) "Setting default printer: " + $pntarray[$findex]
		; $lineno = $lineno + 1
	endif
	$newfline = ReadLine(1)
	$findex = 0
Loop
endif
$ERRH = close(1)

 

And a sample .pnt file would be:

 

printer=\\pc1303\HumsOfficeLaser
default=\\pc1303\HumsOfficeLaser
printer=\\mcprint\a32

 

Any ideas? I can do all this through GP of course, and indeed other ways, just wanted to know if it is possible to retain this .pnt file method.

 

Thanks for absolutely any help! :)

Posted (edited)

edit : have space in my inbox now :) or you can reply here if you want :)

@Steve21 is a lot better than myself with coding / scripts etc, I generally know what I need to look for / google for etc and can for the most part get it working although need to learn neater coding without any illegal bits etc

 

Am sure he could knock something up a lot faster :)

Edited by mac_shinobi

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...