#121068 - 2004-06-11 01:30 AM
Using ReadValue
|
BNutz
Fresh Scripter
Registered: 2001-04-19
Posts: 12
Loc: Washington D.C. USA
|
I think this is a simple question for someone. I am reading the default printer from my registry. I want to make a script that takes this value and turns it into an LPT1 printer. Don't ask, at work using an inhouse app that needs LPT1 mapped (poorly written app). My script is just two lines and will work, but the data in the string has too much info. I need to just grab data up to the comma. The lenghts of the data very so I can't count characters and chop.
Here is what the Default Printer data looks like in the registry: (I need whats in RED only, stopping at the first comma)
\\PrintServer\PrinterName,winspool,Ne01:
Code:
$defprinter = ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device")
USE LPT1: \\$defprinter
Any ideas?
BNutz
|
|
Top
|
|
|
|
#121070 - 2004-06-11 01:50 AM
Re: Using ReadValue
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
|
|
Top
|
|
|
|
#121071 - 2004-06-11 02:17 AM
Re: Using ReadValue
|
BNutz
Fresh Scripter
Registered: 2001-04-19
Posts: 12
Loc: Washington D.C. USA
|
What am I doing wrong? (using 4.21) This seems to just skip right over the "Function" and doesn't do anything. I was doing step by step in debug mode.
Code:
function GetDefaultPrinter() $GetDefaultPrinter = join(split(readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device"),',',1),'') endfunction
? $GetDefaultPrinter
USE LPT1: \\$GetDefaultPrinter
BNutz
|
|
Top
|
|
|
|
#121073 - 2004-06-11 02:38 AM
Re: Using ReadValue
|
BNutz
Fresh Scripter
Registered: 2001-04-19
Posts: 12
Loc: Washington D.C. USA
|
That works! Thanks a million. 'Function' can come in handy, I'll read up on it.
BNutz
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 1046 anonymous users online.
|
|
|