Page 1 of 1 1
Topic Options
#159937 - 2006-03-28 05:32 PM I don't get IDispatch error
Kelly_Dyjur Offline
Fresh Scripter

Registered: 2005-04-05
Posts: 21
I've been looking on the boards for an answer to my particular reason why I'm getting the dreaded IDispatch pointers not allowed error, but I can't find it.

Basically I want to take all installed printers on a computer (I get this with a WMI query), and then record the results to a text file.

The interpreter complains when I try to take the array elements and see if they contain a "\\" (I only want to record mapped printers to the file). I know the answer is on these boards, been looking for hours and now I need to ask for help

Code:

$user_settings = "C:\test.txt"

;Record Printers
$strComputer = "."
$objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\$strComputer\root\cimv2")

$colInstalledPrinters = $objWMIService.ExecQuery ("Select * from Win32_Printer")

Pipe2File($USER_SETTINGS, "[PRINTERS]",1)
For Each $objPrinter in $colInstalledPrinters

;If $objPrinter <> ""
If InStr($objPrinter,"\\") = 1
If $objPrinter.Default = -1
Pipe2File($USER_SETTINGS, $objPrinter.Name + " *default")
Else
Pipe2File($USER_SETTINGS, $objPrinter.Name)
EndIf

EndIf
;EndIf

Next

;Record Network Connections
Pipe2File($USER_SETTINGS, "[NETWORK]",1)
$drivedata = EnumNetworkDrives()
If Ubound($DriveData) <> -1
For $Di = 0 to Ubound($DriveData)
$DriveMap = Split($DriveData[$Di],",",-1)
If $DriveMap[0] <> ""
Pipe2File($USER_SETTINGS, $DriveMap[0] + Chr(9) + $DriveMap[1])
EndIf
Next
Else
Pip2File($USER_SETTINGS, "No drive mappings found.")
EndIf


Top
#159938 - 2006-03-28 06:26 PM Re: I don't get IDispatch error
Kelly_Dyjur Offline
Fresh Scripter

Registered: 2005-04-05
Posts: 21
Moderator, please remove this thread! After two days of looking at this I added 5 characters to the script and it works:
Before: If InStr($objPrinter,"\\") = 1
After: If InStr($objPrinter.name,"\\") = 1

Top
#159939 - 2006-03-28 08:31 PM Re: I don't get IDispatch error
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... if I hadn't come along and posted this, you would have been able to delete your own posts.

The best you can do now is to edit them and remove the embarassing parts.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#159940 - 2006-03-28 10:49 PM Re: I don't get IDispatch error
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Nothing to be embarassed about - we all forget things or overlook things from time to time -
it's part of either being human or getting older (I forget which)

Top
#159941 - 2006-03-29 02:45 AM Re: I don't get IDispatch error
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Definitely part of getting older.. ask any 18 year-old know-it-all.

(trust me, I was one many years ago, and now live with one!)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#183941 - 2007-12-19 02:55 PM Re: I don't get IDispatch error [Re: Glenn Barnas]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Well, I could remove the topic but I am a 38 year old grumpy old bastard moderator and will leave it alone just because I can \:D

[the old mods are a bit slower than the young ones, therefore this late reply :p ]


Edited by Jochen (2007-12-19 02:56 PM)
_________________________



Top
#183947 - 2007-12-19 05:42 PM Re: I don't get IDispatch error [Re: Jochen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Jeez-Louise! What are you - part turtle? Been hibernating?? Or just spending too much time golfing?

Slow to reply is one thing, but Dude!! 19 months???!! You're waaaaay past the "a BIT" part of being slow to respond! \:D

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#183974 - 2007-12-19 09:56 PM Re: I don't get IDispatch error [Re: Glenn Barnas]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Hummmm ... I am an Ent my fast fellow \:\)


Tbh, this afternoon I was bored and followed a link in the who's online section ... I dunno who it was anymore. I realized that it was over a year old after I posted. Then, in the tradition of this topic of not deleting anything, I didn't remove my post
_________________________



Top
Page 1 of 1 1


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

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.071 seconds in which 0.036 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org