Have a look at code i m having problem with.

arrComputers = Array("comp1","comp2","comp3","comp4","comp5")
For Each strComputer In arrComputers
WScript.Echo
WScript.Echo "=========================================="
WScript.Echo "Computer: " & strComputer
WScript.Echo "=========================================="

Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objSWbemLocator.ConnectServer(strServer, _
"root\cimv2", _
strUser, _
strPassword, _
"MS_409", _
"ntlmdomain:" + strDomain)
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "Win32_LogicalDisk instance"
Wscript.Echo "-----------------------------------"
Wscript.Echo "Size: " & objItem.Size
Next
Next

Here Comp2, Comp 3 are in domain1. and Comp 1,4 &5 are in domain2.
When i run the script form Domain 2, It gets me data for Comp 1 but i get
error: Access is denied for rest of the list. Actually it should get data for
Comp4 and 5 but its not. Same when i run from Domain 1 it gives same error
where it should get data form Comp 2 & 3.

I tried to Set ColItems = Nothing but thts also not helping. Plz suggest

Re: Failing to map remote drive. by heintz

heintz
Fri May 09 14:52:28 CDT 2008

On May 9, 2:59=A0am, Shoeb1208 <Shoeb1...@discussions.microsoft.com>
wrote:
> Have a look at code i m having problem with.
>
> arrComputers =3D Array("comp1","comp2","comp3","comp4","comp5")
> For Each strComputer In arrComputers
> =A0 =A0WScript.Echo
> =A0 =A0WScript.Echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D"=

> =A0 =A0WScript.Echo "Computer: " & strComputer
> =A0 =A0WScript.Echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D"=

>
> Set objSWbemLocator =3D CreateObject("WbemScripting.SWbemLocator")
> Set objWMIService =3D objSWbemLocator.ConnectServer(strServer, _
> =A0 =A0 "root\cimv2", _
> =A0 =A0 =A0strUser, _
> =A0 =A0 =A0strPassword, _
> =A0 =A0 =A0"MS_409", _
> =A0 =A0 =A0"ntlmdomain:" + strDomain)
> For Each objItem in colItems
> =A0 =A0 Wscript.Echo "-----------------------------------"
> =A0 =A0 Wscript.Echo "Win32_LogicalDisk instance"
> =A0 =A0 Wscript.Echo "-----------------------------------"
> =A0 =A0 Wscript.Echo "Size: " & objItem.Size
> Next
> Next
>
> Here Comp2, Comp 3 are in =A0domain1. and Comp 1,4 &5 are in domain2.
> When i run the script form Domain 2, It gets me data for Comp 1 but i get
> error: Access is denied for rest of the list. Actually it should get data =
for
> Comp4 and 5 but its not. Same when i run from Domain 1 it gives same error=

> where it should get data form Comp 2 & 3.
>
> I tried to =A0Set ColItems =3D Nothing but thts also not helping. Plz sugg=
est

Look in the machines Event Viewer in the security logs to see if you
are receiving a failed login attempt to the other pc's.

Larry

Re: Failing to map remote drive. by Shoeb1208

Shoeb1208
Sun May 11 21:26:33 CDT 2008

Hi Larry , thanks for the advice. From what i analysed the problem is that
the script is not taking the credentials again for the server in each loop.
Somehow the objWMIService is not getting refreshed after every loop.

any suggestions?

Re: Failing to map remote drive. by heintz

heintz
Tue May 20 15:52:01 CDT 2008

On May 11, 9:26=A0pm, Shoeb1208 <Shoeb1...@discussions.microsoft.com>
wrote:
> Hi Larry , thanks for the advice. From what i analysed the problem is that=

> the script is not taking the credentials again for the server in each loop=
.
> Somehow the objWMIService is not getting refreshed after every loop.
>
> any suggestions?

Just saw the response. Is there a local administrator account on the
machines that have the same username and password you could pass in
the script? You can also add the following to the script so you can
write out the login informaion being passed to the loop.

arrComputers =3D Array("comp1","comp2","comp3","comp4","comp5")
For Each strComputer In arrComputers
WScript.Echo
WScript.Echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D"
WScript.Echo "Computer: " & strComputer
WScript.Echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D"

Set objSWbemLocator =3D CreateObject("WbemScripting.SWbemLocator")
Set objWMIService =3D objSWbemLocator.ConnectServer(strServer, _
"root\cimv2", _
strUser, _
strPassword, _
"MS_409", _
"ntlmdomain:" + strDomain)
wscript.echo "Username:" & strDomain & "\" & strUser _
" Password:" & strPassword
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "Win32_LogicalDisk instance"
Wscript.Echo "-----------------------------------"
Wscript.Echo "Size: " & objItem.Size
Next
Next

Re: Failing to map remote drive. by Tom

Tom
Tue May 20 16:30:10 CDT 2008

On May 20, 4:52 pm, "heintz.la...@gmail.com" <heintz.la...@gmail.com>
wrote:
> On May 11, 9:26 pm, Shoeb1208 <Shoeb1...@discussions.microsoft.com>
> wrote:
>
> > Hi Larry , thanks for the advice. From what i analysed the problem is that
> > the script is not taking the credentials again for the server in each loop.
> > Somehow the objWMIService is not getting refreshed after every loop.
>
> > any suggestions?
>
> Just saw the response. Is there a local administrator account on the
> machines that have the same username and password you could pass in
> the script? You can also add the following to the script so you can
> write out the login informaion being passed to the loop.
>
> arrComputers = Array("comp1","comp2","comp3","comp4","comp5")
> For Each strComputer In arrComputers
> WScript.Echo
> WScript.Echo "=========================================="
> WScript.Echo "Computer: " & strComputer
> WScript.Echo "=========================================="
>
> Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
> Set objWMIService = objSWbemLocator.ConnectServer(strServer, _
> "root\cimv2", _
> strUser, _
> strPassword, _
> "MS_409", _
> "ntlmdomain:" + strDomain)
> wscript.echo "Username:" & strDomain & "\" & strUser _
> " Password:" & strPassword
> For Each objItem in colItems
> Wscript.Echo "-----------------------------------"
> Wscript.Echo "Win32_LogicalDisk instance"
> Wscript.Echo "-----------------------------------"
> Wscript.Echo "Size: " & objItem.Size
> Next
> Next

My guess is that there is an ON ERROR Resume Next statement somewhere
before the code segment posted, because there are multiple errors that
are keeping any useful data from being displayed, even though the
loops still keep running.

For example, the ConnectServer statement references a strServer
variable that is also undefined. Rather, a strComputer variable is
being reference in the FOR loop.

In addition, the colItems collection is undefined in the example.
There needs to be a query, something like before the second FOR
statement ...

Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_LogicalDisk")

It is also not clear that the rest of the needed variables, like
strUser and
strPassword are actually being created. It is also assumed that the
same credentials are valid on all machines. If that's not the case,
the correct credentials for each machine must be keyed to the machine
being queried (which the code fragment does NOT do).

Finally, I would throw in line to clear the connection at the end of
the loop to insure that a new connection is made with each pass. (To
save a little time the Set objSWbemLocator line can be moved out of
the loop and only one instantiation is needed.

Maybe this (untested) ...

On Error Goto 0 ' Clears effect of 'On Error Resume Next'
arrComputers = Array("comp1","comp2","comp3","comp4","comp5")

wscript.echo "Username:" & strDomain & "\" & strUser _
" Password:" & strPassword

Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
For Each strComputer In arrComputers
WScript.Echo
WScript.Echo "=========================================="
WScript.Echo "Computer: " & strComputer
WScript.Echo "=========================================="

Set objWMIService = objSWbemLocator.ConnectServer(strComputer,
_
"root\cimv2", _
strUser, _
strPassword, _
"MS_409", _
"ntlmdomain:" & strDomain)
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_LogicalDisk")
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "Win32_LogicalDisk instance"
Wscript.Echo "-----------------------------------"
Wscript.Echo "Size: " & objItem.Size
Next
Set objWMIService = Nothing
Next

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

Re: Failing to map remote drive. by Todd

Todd
Tue May 20 20:58:35 CDT 2008

Tom Lavedas wrote:
> My guess is that there is an ON ERROR Resume Next statement somewhere
> before the code segment posted, because there are multiple errors that
> are keeping any useful data from being displayed, even though the
> loops still keep running.
...
>
> wscript.echo "Username:" & strDomain & "\" & strUser _
> " Password:" & strPassword

Even with an ON ERROR Resume Next, the carry over line above would still
cause the script to halt. An "&" is required either before the underscore or
at the start of the next line.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)


Re: Failing to map remote drive. by Tom

Tom
Tue May 20 21:51:23 CDT 2008

On May 20, 9:58 pm, "Todd Vargo" <tlva...@sbcglobal.netz> wrote:
> Tom Lavedas wrote:
> > My guess is that there is an ON ERROR Resume Next statement somewhere
> > before the code segment posted, because there are multiple errors that
> > are keeping any useful data from being displayed, even though the
> > loops still keep running.
> ...
>
> > wscript.echo "Username:" & strDomain & "\" & strUser _
> > " Password:" & strPassword
>
> Even with an ON ERROR Resume Next, the carry over line above would still
> cause the script to halt. An "&" is required either before the underscore or
> at the start of the next line.
>
> --
> Todd Vargo
> (Post questions to group only. Remove "z" to email personal messages)

A cut and paste carry over error I missed from Larry Heintz'
contribution. It was not part of the OPs last code sample.

Tom Lavedas
===========

Re: Failing to map remote drive. by Shoeb1208

Shoeb1208
Thu May 22 04:05:02 CDT 2008

Thanks Tom,

The idea was somewhat near.. great help to me.. actually the Error message
was not cleared for each loop and when the loop came back the error was
picked up even when no error was there.. so i did added this small line which
resulted in proper script functioning.

Err.clear

Thank you guys for all your support.