Page 1 of 1 1
Topic Options
#49591 - 2000-04-20 07:41 AM Selecting default printer
Julian Offline
Starting to like KiXtart

Registered: 2000-04-20
Posts: 112
Loc: Newcastle, Staffs, UK
How can I find out what the default printer is in Windoes NT 4.0 using kix?
Top
#49592 - 2000-04-25 10:07 AM Re: Selecting default printer
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Julian,

let kix read the value of 'HKEY_CURRENT_USER\PRINTERS\DeviceOld'.
this is the default Printer on NT 4.0 i think.....
isn't it ???

Jochen

_________________________



Top
#49593 - 2000-04-25 10:21 AM Re: Selecting default printer
Julian Offline
Starting to like KiXtart

Registered: 2000-04-20
Posts: 112
Loc: Newcastle, Staffs, UK
No that isn't where the default printer lies in NT4.0. Basiaclly what i'm trying to do is to get Kix to find out what the default printer is and then write back to an .ini file on the local machine so that the machine knows which tray is headed and which is plain.
Top
#49594 - 2000-04-25 10:57 AM Re: Selecting default printer
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Julian...

You might want to check-out this thread...
http://kixtart.to/script/board/ubbhtml/Forum1/HTML/000766.html

Shawn.

Top
#49595 - 2000-04-28 01:22 PM Re: Selecting default printer
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Here is some code of a big Kixtart script, which calculates at this point de default_printer name + port for Windows 9x/NT/Y2K environments.

code:

$x="" ; - general variable which are used for information -
;
IF (@inwin = 1)
$NT_mode="yes"
ELSE
$NT_mode="no"
ENDIF
;
$default_printer=""
$default_port=""
$defprt=""
;
$ikey="HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows"
IF (ExistKey($ikey) = 0) ; - NT -
$default_printer=ReadValue($ikey, "device")
$default_port=""
IF (INSTR(LCASE($default_printer),",lpt") <> 0)
$default_port=UCASE(substr($default_printer,INSTR(LCASE($default_printer),",lpt")+1,5))
ENDIF
;
IF (len($default_printer) = 0)
$default_printer="NONE"
ENDIF
IF (len($default_port) = 0)
$default_port="NONE"
ENDIF
ENDIF
;
;$ikey="HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\IDConfigDB:CurrentConfig" -> "0001"
$ikey="HKEY_LOCAL_MACHINE\Config\0001\System\CurrentControlSet\Control\Print\Printers"
IF (ExistKey($ikey) = 0) ; - 95 -
$default_printer=ReadValue($ikey, "default")
$default_port=""
$ikey="HKEY_LOCAL_MACHINE\System\CurrentControlSet\control\Print\Printers\"+$default_printer
IF (ExistKey($ikey) = 0)
$default_port=ReadValue($ikey, "Port")
ENDIF
;
IF (len($default_printer) = 0)
$default_printer="NONE"
ENDIF
IF (len($default_port) = 0)
$default_port="NONE"
ENDIF
ENDIF



By this peace of code the variable "$defprt" is calculated.

code:

$defprt=""
IF (len($default_port) <> 0)
IF (INSTR(LCASE($default_port),"lpt") = 0)
$defprt=$defprt+"'"+$default_port+"'"
ELSE
$defprt=$defprt+UCASE($default_port)
ENDIF
$defprt=$defprt+" "
ENDIF
IF (len($default_printer) <> 0)
$defprt=$defprt+"'"
IF (INSTR($default_printer,",") <> 0)
$defprt=$defprt+substr($default_printer,1,INSTR($default_printer,',')-1)
ELSE
$defprt=$defprt+$default_printer
ENDIF
$defprt=$defprt+"'"
ELSE
$defprt=$defprt+"'NONE'"
ENDIF

code:

f.e. '\\FD71001\No03' 'NO03_HP_LJ_5M'


Try it. Greetings.

[This message has been edited by MCA (edited 01 May 2000).]

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#49596 - 2000-04-28 01:30 PM Re: Selecting default printer
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
I was forgotten an example. It gives you an idee what the result can be.

code:

[SPLNX000_NT]
'NONE' mca SPLNX000_NT=00119_000428_14:21:51 spld59672 (NT - vs 3.61 L SPLNX000 \\FD71002) 171.021.093.100 00A024A835EF MCA SPLD59672
'\\FD71001\NO01' nomaint SPLNX000_NT=00119_000428_15:34:48 spld59264 (NT - vs 3.61 L SPLNX000 \\FD71002) 171.021.051.245 00104BB919A2 nomaint SPLD59264

[SPLNX000_95]
'\\FD71001\No03' 'NO03_HP_LJ_5M' no01sf SPLNX000_95=00119_000428_14:59:52 wd57550 (95 - vs 3.61 L SPLNX000 \\FD71002) 171.021.064.057 4000D700E557 NO01SF WD57550
'\\Fd71001\no02' 'HP LaserJet 4MP' no01js SPLNX000_95=00119_000428_15:01:31 wd46027 (95 - vs 3.61 L SPLNX000 \\FD71002) 171.021.064.050 4000D700E550 NO01JS WD46027
'\\FD71001\No03' 'HP LaserJet 5MP' no01rg SPLNX000_95=00119_000428_15:19:09 wd46096 (95 - vs 3.61 L SPLNX000 \\FD71002) 171.021.064.044 4000D700E544 NO01RG WD46096
'\\Fd71001\no02' 'HP LaserJet 4MP LAN' no01rh SPLNX000_95=00119_000428_15:31:26 wd59746 (95 - vs 3.61 L SPLNX000 \\FD71002) 171.021.064.032 4000D700E532 NO01RH WD59746
LPT1: 'HP LaserJet 4000 PCL 6 LOCAL' no01pv SPLNX000_95=00119_000428_15:26:10 wd46028 (95 - vs 3.61 L SPLNX000 \\FD71002) 171.021.064.029 4000D700E529 NO01PV WD46028
'\\Fd71001\no05' 'HP DeskJet 895C Series Printer' no01th SPLNX000_95=00119_000428_17:01:50 wd46025 (95 - vs 3.61 L SPLNX000 \\FD71002) 171.021.064.051 4000D700E551 NO01TH WD46025


Following piece of code can create a list of all LOCAL connected printers. Based on calculated variables earlier in script.

code:

; - $default_printer (previously calculated) -
; - $default_port (previously calculated) -
; - $temp (previously calculated) f.e. (NT - vs 3.61 L SPLNX000 \\FD71002) 171.021.093.100 00A024A835EF MCA
; - $debug_mode (set earlier)
; - $domain (previously calculated) f.e. SPLNX000
; - $key (set earlier) f.e. 00119_000428_15:34:48
; - $user (previously calculated) f.e. MCA
;
$file="X:\info\local.lst"
IF ($NT_mode = "yes")
$section_x=$domain+"_NT"
ELSE
$section_x=$domain+"_95"
ENDIF
$key_x=substr(LCASE($user) +" ",1,15)+" "
$key_x=$key_x+$section_x
$xxx=""
IF (INSTR(LCASE($default_port),"lpt") <> 0)
$xxx=$xxx+substr($key,1,22)
$xxx=$xxx+substr(LCASE(@wksta)+" ",1,15)+" "
$xxx=$xxx+substr($defprt+" ",1,55)+" "
$xxx=$xxx+$tmp
ENDIF
;
IF ($debug_mode = "yes")
?
? " file_y = "+$file_y
? " section_x = "+$section_x
? " key_x = "+$key_x
? " xxx = "+$xxx
? " default_prt = "+$default_printer
? " port "+$default_port
? " defprt = "+$defprt
?
ENDIF
IF writeprofilestring($file, $section_x, $key_x, $xxx)
ENDIF


Greetings

[This message has been edited by MCA (edited 01 May 2000).]

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2419 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.058 seconds in which 0.028 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