Script error

Getting error Line 39 Char 3 error ox80041001 on the following script that was working but now is not.  Also does anyone know how to pass my login credintials to the computer just for this job

'Script to get Programs install on list of Computer on a Network
'
'connect to doman
'
 
  Const FOR_APPENDING = 8
  Const FOR_READING = 1
   
  strFilename = "c:\hosts.txt"
  strOutputFile = "xpsp.txt"
   
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set objTextStream = objFSO.OpenTextFile(strFilename, FOR_READING)
   
    Set objFSO2 = CreateObject("Scripting.FileSystemObject")
        If objFSO2.FileExists(strOutputFile) Then
                Set objTextStream2 = objFSO2.OpenTextFile(strOutputFile, FOR_APPENDING)
        Else
                Set objTextStream2 = objFSO2.CreateTextFile(strOutputFile)
        End If
 
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
'
'Read list of computer, get installed products
'
Do Until objTextStream.AtEndOfStream
  strComputer = objTextStream.readline
  Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
  Set colItems = objWMIService.ExecQuery("Select * from Win32_Product")
'
'
'Output to file
'
  objTextStream2.WriteLine "The Computer:" & strComputer
  For Each objItem in colItems
    objTextStream2.WriteLine objItem.Description &  " (v." & objItem.Version & ")"
  Next
Loop
terryshort77Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobSampsonCommented:
Hi, the script looks like it should work fine, provided that the account you use to run it as (presumably your user account) has admin access to the remote machine, and also that WMI is functioning correctly on each remote machine.

I have added a bit of error checking just in case there is a WMI problem, but as far as passing your login credentials....that's already done as soon as you run the script while logged in as yourself.

You don't need the AD connection part of this script either....WMI doesn't use that.

Regards,

Rob.
Const FOR_APPENDING = 8 
Const FOR_READING = 1 

strFilename = "c:\hosts.txt" 
strOutputFile = "xpsp.txt" 

Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objTextStream = objFSO.OpenTextFile(strFilename, FOR_READING, False)
   
Set objTextStream2 = objFSO.OpenTextFile(strOutputFile, FOR_APPENDING, True)

' 
'Read list of computer, get installed products 
' 
Do Until objTextStream.AtEndOfStream 
	strComputer = objTextStream.readline 
	Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") 
	Set colItems = objWMIService.ExecQuery("Select * from Win32_Product") 
	' 
	'Output to file 
	' 
	objTextStream2.WriteLine "The Computer:" & strComputer 
	On Error Resume Next
	For Each objItem In colItems 
		objTextStream2.WriteLine objItem.Description &  " (v." & objItem.Version & ")" 
	Next
	If Err.Number <> 0 Then
		objTextStream2.WriteLine "ERROR " & Err.Number & ": " & Err.Description
		Err.Clear
	End If
	On Error GoTo 0
Loop
objTextStream2.Close
objTextStream.Close

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.