Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wmi - ConnectServer

Status
Not open for further replies.

Serenades

Programmer
Oct 3, 2001
21
SE
Hi,

Im trying to query my servers health through VBScript but without luck.
My script only returns "Access denied" (or similar...).

The script is run from a Win2000 server and query other Win2000 servers.

I guess i must have a user account on the remote machine, i´ve created a new user and added this to Administrator-group, i then try to send this userinformation with the script (strUser & strPassword) but without luck.


* I dont want to put one script on each server which is running local... *



Best regards
Robert



--- script ---
Option Explicit

Dim strComputer, strUser, strPassword
Do
strComputer = inputbox( "Please enter computername (or . for local host)", "Input" )
Loop until strComputer <> &quot;&quot;
Do
strUser = inputbox( &quot;Please enter username&quot;, &quot;Input&quot; )
Loop until strUser <> &quot;&quot;
Do
strPassword = inputbox( &quot;Please enter password&quot;, &quot;Input&quot; )
Loop until strPassword <> &quot;&quot;
ListShares strComputer, strUser, strPassword

WScript.Echo vbCrlf & &quot;Ready.&quot;


Sub ListShares( strComputer, strUser, strPassword )
Dim strObject
Dim objLocator, objWMIService, objShare
Dim colShares


Set objLocator = CreateObject(&quot;WbemScripting.SWbemLocator&quot;)
Set objWMIService = objLocator.ConnectServer(strComputer, &quot;root\cimv2&quot;)', strUser, strPassword)
objWMIService.Security_.ImpersonationLevel = 3
Set colShares = objWMIService.ExecQuery( &quot;Select * from Win32_Share&quot; )
For Each objShare In colShares
Wscript.Echo objShare.Name & &quot; [&quot; & objShare.Path & &quot;]&quot;
Next
End Sub
--- //end script ---
 
are you logged on to the system you are running it from as a Domain Administrator? and are these systems on the same domain?
 
Solved the problem.
I first had to enabled DCOM, then i added a new account as the only one allowed to execute scripts (except SYSTEM).
Added the new account as Administrator...

Attaching my account information with the script at run time.

Thanks for your help anyway.

//R
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top