Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Detecting Shared Printers

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,64140
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Detecting Shared Printers
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Detecting Shared Printers - 9/9/2008 3:23:03 AM   
  SytnerIT

 

Posts: 12
Score: 0
Joined: 9/2/2008
Status: offline
Hi

I am currently trying to create a script that detects the printer shares on a remote device.
I am currently using the GetObject method but this is giving me  "Permission denied: 'GetObject' when connecting to the remote device.

Set objWMIService = GetObject("winmgmts:\\PrintServerName\root\cimv2")
Set colPrinters = objWMIService.ExecQuery _
("Select * From Win32_Printer Where Local = False")
For Each objPrinter in colPrinters
MsgBox(objPrinter.name)
Next

Is it a problem that the account I am running the script in does not have administrator rights on the remote machine?

If so is there another way to get the collection?

Yours hopefully

Rob
SytnerIT

 
 
Post #: 1
 
 RE: Detecting Shared Printers - 9/9/2008 10:32:22 AM   
  dm_4ever


Posts: 2669
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
WMI requires that you have administrative rights on the remote machine you are trying to get information from.  Also, getting printer information is very similar to getting mapped drives....it is very difficult and not straight forward since it is by user profile....you can get some of this info from the registry....but this too requires a level of administrative rights.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to SytnerIT)
 
 
Post #: 2
 
 RE: Detecting Shared Printers - 9/9/2008 6:55:52 PM   
  SytnerIT

 

Posts: 12
Score: 0
Joined: 9/2/2008
Status: offline
Thanks for the info, much appreciated.

I am trying to detect the printers (on a print server) which are set up as shared ones.

My aim is to create an HTA that detects the available printers on the server, then present this info to the user.

They can then choose the printer they want to connect to.

Cheers

Rob


(in reply to SytnerIT)
 
 
Post #: 3
 
 RE: Detecting Shared Printers - 9/10/2008 1:27:37 AM   
  dm_4ever


Posts: 2669
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
In this case Win32_Printer would work since the printers are actually on the server...however you still require administrative rights to query for this.

What if you used net view \\printservername and parse the information

...maybe someone else has another idea

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to SytnerIT)
 
 
Post #: 4
 
 RE: Detecting Shared Printers - 9/10/2008 1:34:48 AM   
  SytnerIT

 

Posts: 12
Score: 0
Joined: 9/2/2008
Status: offline
How would I get this into my script, I would usually run this from cmd prompt.

If I could get the output into a string or array variable I  maybe able to get this to work.

Do you have any suggestions for getting the output of "netview" into my script.

Cheers

Rob

(in reply to SytnerIT)
 
 
Post #: 5
 
 RE: Detecting Shared Printers - 9/10/2008 1:55:17 AM   
  dm_4ever


Posts: 2669
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Not a complete solution...but should get you started


      

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to SytnerIT)
 
 
Post #: 6
 
 RE: Detecting Shared Printers - 9/10/2008 10:49:26 PM   
  SytnerIT

 

Posts: 12
Score: 0
Joined: 9/2/2008
Status: offline
Thanks for this I have got this working! Much appreciated.

I am now inserting this into an HTA.

Each printer found will have a button created for it.

However I am having trouble using the output variable name (foreach printer) as the label for the button.

Don't know if I need to start a new string for an HTA enquiry or not, if so please state in reply and I will.

If you could help that would be great, the VBScript part of my HTA is below:

<script language="VBScript">
Option Explicit
Dim objWshShell
Dim strPrintServer
Dim objExec
Dim strTemp
Dim intPrintPosition
Dim strPrinterShareName

strPrintServer = "Thruxton"
Set objWshShell = CreateObject("WScript.Shell")
Set objExec = objWshShell.Exec("net view \\" & strPrintServer)
Do Until objExec.StdOut.AtEndOfStream
  strTemp = objExec.StdOut.ReadLine
  If InStr(UCase(strTemp), "PRN:") > 0 Then
      intPrintPosition = InStrRev(UCase(strTemp), "PRINT")
   strPrinterShareName = Trim(Left(strTemp, (intPrintPosition-1)))
   Document.Write "<button>strPrinterShareName</button><br>"
  End If
Loop
</script>


Yours hopefully
Rob
SytnerIT

(in reply to SytnerIT)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Detecting Shared Printers Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts