- Home
·
- Miscellaneous
·
- WMI sample showing how to impersonate. It shows how to list all shares on a remote computer using d
WMI sample showing how to impersonate. It shows how to list all shares on a remote computer using d
WMI sample showing how to impersonate. It shows how to list all shares on a remote computer using different credentials, also called
Rate WMI sample showing how to impersonate. It shows how to list all shares on a remote computer using d
(1(1 Vote))
' This function lists all shares on a remote computer, using different
' credentials than the currently logged on user.
' Check out http://www.activxperts.com/activmonitor for more samples and
' components
Option Explicit
Sub ListShares( strComputer, strUser, strPassword )
Dim strObject
Dim objLocator, objWMIService, objShare
Dim colShares
Set objLocator = CreateObject( "WbemScripting.SWbemLocator" )
Set objWMIService = objLocator.ConnectServer ( strComputer, "root/cimv2", strUser, strPassword )
objWMIService.Security_.impersonationlevel = 3
Set colShares = objWMIService.ExecQuery( "Select * from Win32_Share" )
For Each objShare In colShares
Wscript.Echo objShare.Name & " [" & objShare.Path & "]"
Next
End Sub
' Main
Dim strComputer, strUser, strPassword
Do
strComputer = inputbox( "Please enter the name of a computer in your network (or . for local host)", "Input" )
Loop until strComputer <> ""
Do
strUser = inputbox( "Please enter username", "Input" )
Loop until strUser <> ""
Do
strPassword = inputbox( "Please enter password", "Input" )
Loop until strPassword <> ""
ListShares strComputer, strUser, strPassword
WScript.Echo( vbCrlf & "Ready." & vbCrlf & "Check out http://www.activxperts.com for more samples and components." )
WMI sample showing how to impersonate. It shows how to list all shares on a remote computer using d Comments
No comments yet — be the first to post one!
Post a Comment