#159937 - 2006-03-28 05:32 PM
I don't get IDispatch error
|
Kelly_Dyjur
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
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
|
|
|
|
#159940 - 2006-03-28 10:49 PM
Re: I don't get IDispatch error
|
NTDOC
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
|
|
|
|
#183974 - 2007-12-19 09:56 PM
Re: I don't get IDispatch error
[Re: Glenn Barnas]
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|