|
|
|||||||
HI! I´m trying to make a script that maps printers to a thin client and the script should assign printers based on the computer names, the 6 first charachter in the name. The script should map a couple of printers and make one of them the default printer. Does anyone have a good example? I have about 60 printers that need to be mapped. Thanks in advance Riwe |
||||||||
|
|
|||||||
Can I ask a question? Why? Why do you need to map/re-map a printer? If you can capture the client printer to LPT1, MetaFrame picks up the client printer fine. We use printers this way with no problem.. The other things is if you clean out the cleint profiles from the servers in your farm using DELPROF or other means, these would have to be re-built at each server, Thanks, Kent |
||||||||
|
|
|||||||
Quote: ...so no local printer configuration (other than LPT1 possibly) |
||||||||
|
|
|||||||
Because all our printers are network printers, and all our clients are using thinstation linux dist. Today all printers get mapped by a vbscript, I´m trying to move all the different script in one kix file, I don´t want to use vbscript anymore. /Riwe |
||||||||
|
|
|||||||
Assuming the computer names come though as something like: "SITE01-0001" "SITE01-0002" "SITE23-0982" Create an INI file on your netlogon share like this: Code: [SITE01] ...and so on. Now in your script you can (untested!): Code: For Each $sPrinter in Split(ReadProfileString("%LOGONSERVER%\netlogon\printers.ini",Left(%CLIENTNAME%,6),""),Chr(10)) |
||||||||
|
|
|||||||
Thanks four replays. I tried this and it worked, now is my question is this code good? Whats the difference between IF ADDPRINTERCONNECTION ("\\w2k3dc\hpl4") =0 ? "Printer added" AND ADDPRINTERCONNECTION ("\\w2k3dc\hpl4") ? should I close every IF with and ENDIF eg. IF ADDPRINTERCONNECTION ("\\w2k3dc\hpl4") =0 ? "Printer added" ENDIF IF ADDPRINTERCONNECTION ... Script: ;Delete all existing networkprinters DelTree("HKEY_CURRENT_USER\Printers\Connections") AddKey("HKEY_CURRENT_USER\Printers\Connections") ;Check location depending on clientname $Datornamn = LEFT(%clientname%,6) ;Connect the right printer to this terminal SELECT CASE ($Datornamn = TSPS18) IF ADDPRINTERCONNECTION ("\\w2k3dc\hpl4") =0 ? "Printer added" IF ADDPRINTERCONNECTION ("\\w2k3dc\hp") =0 ? "Printer added" IF SETDEFAULTPRINTER ("\\w2k3dc\hp") =0 ? "Default printer" CASE 1 $Selection = MessageBox("Clientname unknown. No printer connections available at this moment. Please contact you system administrator.", "Printerinfo", 64) IF $Selection = 1 EXIT ENDIF ENDSELECT |
||||||||
|
|
|||||||
Quote: Yes. |
||||||||
|
|
|||||||
See also the two FAQs Why does the console display zeros and ones (amongst others)? Is '?' a PRINT or NEWLINE command? |