ioliver Posted August 3, 2004 Posted August 3, 2004 I didn't know what category this fell into, so I thought I'd post it here. Does anyone have a script that will list current printer connections for a remote PC? Let me know if you need more info. Thanks, Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF
this-is-me Posted August 3, 2004 Posted August 3, 2004 Does "net view \\computername" do what you need? Who else would I be?
ioliver Posted August 3, 2004 Author Posted August 3, 2004 No, 'net view \\computername' show what shares are available on a computer, not what shares the computer is connected to. Thanks, Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF
Holger Posted August 4, 2004 Posted August 4, 2004 (edited) Do you mean normal printer-connections that has a user?Is the key:HKEY_CURRENT_USER\Printers\Connectionsnot what you want?In the subkeys you find the printer-connections which you could readout with "RegEnumKey". Edited August 4, 2004 by Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView
_itch Posted August 4, 2004 Posted August 4, 2004 The code might be mickey mouse as I am just starting myself, but this will create a batch file on the user's desktop so that the user can re-install printers whenever they need to.. Hope this helps _ITCH $PRINTER_FILE = @UserProfileDir & "\desktop\" & @Username & "_printers.bat" FileDelete ( $PRINTER_FILE ) $PRINTER = "default blank entry" $I = 1 $READ_PRINTER = "test" FileDelete("c:\temp.txt") DO $READ_PRINTER = RegEnumKey("HKEY_CURRENT_USER\Printers\Connections", $i) $TEMP_VAR = StringReplace($READ_PRINTER, ",", "\") IF $TEMP_VAR = "" THEN $TEMP_VAR = "CLS" ELSE FileWriteLine ($PRINTER_FILE, "Start " & $TEMP_VAR) FileWriteLine ("c:\temp.txt", $TEMP_VAR) $i = $i + 1 ENDIF Until $READ_PRINTER = ""
ioliver Posted August 4, 2004 Author Posted August 4, 2004 Thanks Holger,HKEY_CURRENT_USER\Printers\ConnectionsI think that Reg Key is what I was looking for. Now I just need to have AutoIT read a Remote Registy.Thanks again,Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF
Holger Posted August 4, 2004 Posted August 4, 2004 (edited) @ioliver: you can use:Reg...("\\remotepc\HK...) Edited August 4, 2004 by Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView
ioliver Posted August 4, 2004 Author Posted August 4, 2004 Is the HKEY_CURRENT_USER Key available remotely? Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF
Holger Posted August 5, 2004 Posted August 5, 2004 Don't know, but HKEY_Users should be...maybe it's a little bit more complex to readout all this, but should be possible... Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView
commenti Posted August 5, 2004 Posted August 5, 2004 Hi ioliver,I am wondering you did not find this with a formum search. I asked this question some days ago myself here: http://www.autoitscript.com/forum/index.ph...wtopic=3913&hl=So you might find this interessting.Here are the functions I wrote after receiving the info:expandcollapse popup; ---------------------------------------------------------------------------- ; Function setdefaultprinter ; currently gives not feedback if function was successfull or not. ; ---------------------------------------------------------------------------- Func setdefaultprinter ($PRINTERSHARE) RunWait(@ComSpec & " /c RUNDLL32 PRINTUI.DLL,PrintUIEntry /q /y /n " & '"' & $PRINTERSHARE & '"', "", @SW_HIDE) EndFunc ; ---------------------------------------------------------------------------- ; Function delprinterconnection ; Deletes a printershare connection ; currently gives not feedback if function was successfull or not. ; ---------------------------------------------------------------------------- Func delprinterconnection ($PRINTERSHARE) $printerconnectioncount = 0 while 1 $printerconnectioncount = $printerconnectioncount +1 $printerconnectionname= StringSplit ( RegEnumKey ("HKEY_CURRENT_USER\Printers\Connections",$printerconnectioncount), "," ); examine if exists. if (@error = 1) Then ExitLoop EndIf $printername = StringSplit ( $printershare, "\" ) if $printername[$printername[0]] = $printerconnectionname[$printerconnectionname[0]] Then;only delete printer connnection if it RunWait(@ComSpec & " /c RUNDLL32 PRINTUI.DLL,PrintUIEntry /q /dn /n " & '"' & $PRINTERSHARE & '"', "", @SW_HIDE);exist (this makes login script much faster) EndIf wend EndFunc ; ---------------------------------------------------------------------------- ; Function delprinterconnection ; Connect to a printershare ; currently gives not feedback if function was successfull or not. ; ---------------------------------------------------------------------------- Func addprinterconnection ($PRINTERSHARE) RunWait(@ComSpec & " /c RUNDLL32 PRINTUI.DLL,PrintUIEntry /q /in /n " & '"' & $PRINTERSHARE & '"', "", @SW_HIDE) EndFuncNote: Functions are tested only with german versions of Win2000 and WinXP.A function to list all connections, I don´t have at the moment, but it can easily be done, so if you don´t get a function for this scripted yourself, just ask again. commenti
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now