Page 1 of 1 1
Topic Options
#168504 - 2006-09-26 11:42 AM Printer Check Logon Script
KixLearner Offline
Fresh Scripter

Registered: 2006-09-26
Posts: 7
Loc: England
Hi,

I am very new to Kix scripts and just wondered if it was possible to have a script that can run on logon and check what printers are mapped on the PC and then export that information to a text file?

Any help would be greatly appreciated.

Many Thanks,

Ben

Top
#168505 - 2006-09-26 11:45 AM Re: Printer Check Logon Script
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
There is PrinterList, EnumPrinterConnections and EnumPrinterConnections2 in the UDF library. Would they be of any help?
Top
#168506 - 2006-09-26 11:48 AM Re: Printer Check Logon Script
KixLearner Offline
Fresh Scripter

Registered: 2006-09-26
Posts: 7
Loc: England
Sounds promising. As I am new to this site could you point me in the right direction please?
Top
#168507 - 2006-09-26 11:51 AM Re: Printer Check Logon Script
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
http://www.kixtart.org/ubbthreads/ubbthreads.php?Cat=0
Click "UDF Library"
Click "Search" (on top)
Type in some search words and change options if needed
Click "Submit"

Top
#168508 - 2006-09-26 12:11 PM Re: Printer Check Logon Script
KixLearner Offline
Fresh Scripter

Registered: 2006-09-26
Posts: 7
Loc: England
Thanks for that, much appreciated.

Does this one:

http://www.kixtart.org/ubbthreads/showfl...true#Post137527

Export the results to a text file anywhere? Sorry if its a stupid question or obvious answer

Top
#168509 - 2006-09-26 12:22 PM Re: Printer Check Logon Script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
no, udf's are user defined functions.
they work just as kixtart functions (at least theoretically)...
as example, open() is a function.
it does not export anything to file, it just opens the file.

same goes with that udf.
it returns you the list of printers and if you want to place the data to a file, write couple of lines of script with open(), writeline() and close() to do the actual exporting.

Top
#168510 - 2006-09-26 12:37 PM Re: Printer Check Logon Script
KixLearner Offline
Fresh Scripter

Registered: 2006-09-26
Posts: 7
Loc: England
OK thanks for the info. I will post a new topic asking how to create, open, import the variable details and close a text file as I dont want this one to go off topice.

Many thanks for your help

Top
#168511 - 2006-09-26 03:22 PM Re: Printer Check Logon Script
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Code:

If NOT @LOGONMODE
Break On
Else
Break Off
EndIf
Dim $RC
$RC = SetOption("Explicit","On")
$RC = SetOption("NoVarsInStrings","On")
$RC = SetOption("NoMacrosInStrings","On")
$RC = SetOption("WrapAtEOL","On")

Dim $aPrinters, $Printer, $Handle1, $File1
$aPrinters = EnumPrinterConnections2()
$Handle1 = FreeFileHandle()
$File1 = @SCRIPTDIR + "\" + Left(@SCRIPTNAME,Len(@SCRIPTNAME)-4) + ".txt"
If Open($Handle1,$File1,5) = 0
For Each $Printer in $aPrinters
$RC = WriteLine($Handle1,$Printer + @CRLF)
Next
$RC = Close($Handle1)
Else
? "Error opening or creating file: " + $File1
? "Error " + @ERROR + ": " + @SERROR
EndIf


Top
#168512 - 2006-09-26 03:28 PM Re: Printer Check Logon Script
KixLearner Offline
Fresh Scripter

Registered: 2006-09-26
Posts: 7
Loc: England
Cool thanks for the code. I ran that and it just created an empty text file yet I have 2 mapped network printers. Any ideas?

I do appreciate all your help with this.

Top
#168513 - 2006-09-26 03:31 PM Re: Printer Check Logon Script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Did you copy/paste the UDF into the test script?
Top
#168514 - 2006-09-26 03:38 PM Re: Printer Check Logon Script
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
You could also include the UDF and store it in a different file
Code:

Include = "\\Servername\Sharename\EnumPrinterConnections2.udf"


Top
#168515 - 2006-09-26 03:45 PM Re: Printer Check Logon Script
KixLearner Offline
Fresh Scripter

Registered: 2006-09-26
Posts: 7
Loc: England
I was being a muppet and forgot to link in the UDF bit. Works like a treat now - thank you VERY much for all your help!
Top
#168516 - 2006-09-26 03:47 PM Re: Printer Check Logon Script
KixLearner Offline
Fresh Scripter

Registered: 2006-09-26
Posts: 7
Loc: England
One last and very cheeky question, is there a way to make the exported text file the same name as the PC name? ie PC Name = ID1234 would create ID1234.txt

????

Top
#168517 - 2006-09-26 04:09 PM Re: Printer Check Logon Script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
yes, use the @wksta macro.
Top
Page 1 of 1 1


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

Who's Online
0 registered and 152 anonymous users online.
Newest Members
Jodey, Hiker, GTRoberts, KatieQuinn, Brennnnn
17684 Registered Users

Generated in 0.04 seconds in which 0.012 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