P
polykobol
I'm looking for a very simple way in VBScript for checking if the
current user has Administrative rights on his Windows XP machine. I
searched through the web and came up with this:
http://groups.msn.com/windowsscript...n=view_list&row=35&viewtype=2&sortstring=1a2a
Since I cannot be sure which drives the users has mapped already I
simply tried to remove the drive letter and it seems to work!
Function CurrentUserIsAdministrator()
Dim nw
CurrentUserIsAdministrator = True
Set nw = WScript.CreateObject("WScript.Network")
On Error Resume Next
nw.MapNetworkDrive "", "\\" & nw.ComputerName & "\Admin$"
If Err.number <> 0 Then
CurrentUserIsAdministrator = False
Err.Clear
End If
On Error Goto 0
End Function
What exactly does the above do? It seems to work exactly the way I
want it to, but according to MS the first parameter of MapNetworkDrive
cannot be empty. If I try to map a shared folder manually I also have
the option "(none)" to choose from among all the drive letters. The
only thing that happens then seems to be that the folder opens...or is
something happening that I don't notice?
current user has Administrative rights on his Windows XP machine. I
searched through the web and came up with this:
http://groups.msn.com/windowsscript...n=view_list&row=35&viewtype=2&sortstring=1a2a
Since I cannot be sure which drives the users has mapped already I
simply tried to remove the drive letter and it seems to work!
Function CurrentUserIsAdministrator()
Dim nw
CurrentUserIsAdministrator = True
Set nw = WScript.CreateObject("WScript.Network")
On Error Resume Next
nw.MapNetworkDrive "", "\\" & nw.ComputerName & "\Admin$"
If Err.number <> 0 Then
CurrentUserIsAdministrator = False
Err.Clear
End If
On Error Goto 0
End Function
What exactly does the above do? It seems to work exactly the way I
want it to, but according to MS the first parameter of MapNetworkDrive
cannot be empty. If I try to map a shared folder manually I also have
the option "(none)" to choose from among all the drive letters. The
only thing that happens then seems to be that the folder opens...or is
something happening that I don't notice?