In the script below and all other scripts I have that I run against Win2k3
boxes I get an error. The error is:

Line: 33
Char: 1
Error: Permission denied:'GetObject'
Code: 800A0046

What am I doing wrong.

'--------------------------------------------------------------------
' This script looks for a CSV file in the same directory as this script to.
' pull server names from.
'--------------------------------------------------------------------
Dim fsoIn, fsoOut
Dim inFile, outFile
Dim arrComputerNames
Dim objUser
Dim strComputer
Dim ErrorOccurred
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const inFilename = "servers.csv"
Const outFilename = "STARTTelnet.log"

'On Error Resume Next
ErrorOccurred = False

' Open the input file and skip the header line
Set fsoIn = CreateObject("scripting.filesystemobject")
Set inFile = fsoIn.OpenTextFile(inFilename, ForReading, True)
inFile.Skipline

While Not inFile.AtEndOfStream
arrComputerNames = Split(inFile.Readline, vbTab, -1, 1)
' arrComputerNames(0) contains the computer name
strComputer = arrComputerNames(0)
'--------------------------------------------------------------------
'This section sets up the information.
'--------------------------------------------------------------------
'THIS IS LINE 32 the one below is the one I'm havin' trouble with!!!
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\sp1\sp1.exe" , "\\" & strComputer & _
"\c$\SP1\sp1.exe", OverwriteExisting

'Next
Wend
Wscript.Echo "Done"

RE: Error running scripts against W2K3 boxes. by mark

mark
Tue Mar 14 14:59:28 CST 2006

Hi kb,

I presume there is a section of the script missing as I cant see any reason
you need to connect to wmi in order to copy the file from the source machine
to the target machine.

On the surface the issue does appear to be permission related. Line 33 is
the first point in the script that you try and coonect to the remote machine
and you are denied access.

does the account you are using to run the script have admin rights on the
remote machine?

Mark

"kb" wrote:

> In the script below and all other scripts I have that I run against Win2k3
> boxes I get an error. The error is:
>
> Line: 33
> Char: 1
> Error: Permission denied:'GetObject'
> Code: 800A0046
>
> What am I doing wrong.
>
> '--------------------------------------------------------------------
> ' This script looks for a CSV file in the same directory as this script to.
> ' pull server names from.
> '--------------------------------------------------------------------
> Dim fsoIn, fsoOut
> Dim inFile, outFile
> Dim arrComputerNames
> Dim objUser
> Dim strComputer
> Dim ErrorOccurred
> Const ForReading = 1
> Const ForWriting = 2
> Const ForAppending = 8
> Const inFilename = "servers.csv"
> Const outFilename = "STARTTelnet.log"
>
> 'On Error Resume Next
> ErrorOccurred = False
>
> ' Open the input file and skip the header line
> Set fsoIn = CreateObject("scripting.filesystemobject")
> Set inFile = fsoIn.OpenTextFile(inFilename, ForReading, True)
> inFile.Skipline
>
> While Not inFile.AtEndOfStream
> arrComputerNames = Split(inFile.Readline, vbTab, -1, 1)
> ' arrComputerNames(0) contains the computer name
> strComputer = arrComputerNames(0)
> '--------------------------------------------------------------------
> 'This section sets up the information.
> '--------------------------------------------------------------------
> 'THIS IS LINE 32 the one below is the one I'm havin' trouble with!!!
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> objFSO.CopyFile "C:\sp1\sp1.exe" , "\\" & strComputer & _
> "\c$\SP1\sp1.exe", OverwriteExisting
>
> 'Next
> Wend
> Wscript.Echo "Done"