Page 1 of 1 1
Topic Options
#150516 - 2005-10-25 01:24 AM Windows 98 Printer install
Smerfkila Offline
Lurker

Registered: 2005-10-21
Posts: 2
This script will check to see if a certian printer is installed. If it is not installed it will install it. If it is installed it will move on.

Since I am new to scripting, It drove me nuts trying to find a script that does this. So thsi is for all the newbs.

Also All you need to do with this script is change the server and newprinter vars to suit your needs.


Questions or comments are welcome. Enjoy!

Code:

; This script checks for the existence of a printer
; if the printer does not exists then it installs a new printer

break on
$server = "yourserver"
$newprinter = "yourprinter"
$localkey = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\control\Print\Printers"
$sep = "\"
$Index = 0
:Loop1
$PRINTER = ENUMKEY ($localkey,$Index)
;$PORT=ENUMVALUE ("$localkey\$PRINTER",5)
$KeyName=READVALUE ("$localkey\$PRINTER","PORT")
If @ERROR = 0
? "Name found: $KeyName"
$lenkey = len($keyname)
$keyname = substr($keyname,3,$lenkey - 2)
$comma = instr($keyname,$sep)
$servername = substr($keyname,1,$comma-1)
$Printer = substr($keyname,$comma+1,$lenkey - $comma - 1)
" Server = $Servername, Printer = $printer"
if $printer = ""
GOTO Installprinter
endif
if $printer = $newprinter
GOTO End
endif
$Index = $Index + 1
goto Loop1
Endif
:Installprinter
RUN "rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL AddPrinter"
? "Please Wait"
sleep 3
sendkeys("{ENTER}")
sendkeys("~N")
sendkeys("{ENTER}")
sleep 1
sendkeys("~P")
sendkeys("\\$server\$newprinter")
sleep 1
sendkeys("~N")
sendkeys("{ENTER}")
sendkeys("{TAB}")
sendkeys("{TAB}")
sendkeys("{ENTER}")
sendkeys("~N")
sendkeys("{ENTER}")
sleep 3

:End



Props to Mystic Mike whom I stole the Loop segment of thsi code from.

Top
#150517 - 2005-10-25 02:27 AM Re: Windows 98 Printer install
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well thanks and welcome to the board Smerfkila

Not sure if you noticed but we have like 560+ UDF scripts that can handle just about any task you can think of including installing or moving printers around.

Not sure what's up with the need for SENDKEYS either, but again - thanks for sharing.

Top
#150518 - 2005-10-26 12:29 AM Re: Windows 98 Printer install
Smerfkila Offline
Lurker

Registered: 2005-10-21
Posts: 2
It basically goes though the install of a printer on windows 98 because I am unable to find a script that will install the printer on Windows 98.. If anyone has a better idea or Even a link to a comamnd that works with 98 (not addprinter cause that dosnt work) It would be very much appreciated
Top
#150519 - 2005-10-27 03:12 PM Re: Windows 98 Printer install
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
AddPrinter() UDF does not work because it's written for Windows 2000 and up, as specified in the UDF header.

And before reinventing the wheel, you should have used the BBS Search to find posts like this: printer installation in Win 98 and Win9x printers
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1607 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.088 seconds in which 0.055 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org