From: ajm1949 on
How can I determine if a user is logged in as an Administrator or as a
standard user without Admin priveleges
From: Gary Keramidas on
i cobbled this together, give it a try. it wil put the group in A1 on sheet1

Sub test()
Dim ws As Worksheet
Dim fs As Object

Dim WholeLine As String
Set fs = CreateObject("Scripting.FileSystemObject")
Set ws = Worksheets("Sheet1")
Shell ("C:\windows\system32\cmd /k net user " & Environ("username") &
" > d:\test.txt")

Do
Loop Until fs.fileexists("D:\test.txt")
Open "D:\test.txt" For Input Access Read As #1

Do Until InStr(1, WholeLine, "Local Group Memberships")
Line Input #1, WholeLine
Loop
ws.Range("A1").Value = Trim(Split(WholeLine, "*")(1))
Close #1
fs.deleteFile "D:\test.txt"

End Sub


--


Gary Keramidas
Excel 2003


"ajm1949" <ajm1949(a)discussions.microsoft.com> wrote in message
news:A1E58164-3D47-4BEA-A402-6BC09D12A661(a)microsoft.com...
> How can I determine if a user is logged in as an Administrator or as a
> standard user without Admin priveleges

From: Gary Keramidas on
one other thing i forgot to mention, it uses the D Drive, if you don't have
one, here's one that will work with the C Drive

Sub test2()
Dim ws As Worksheet
Dim fs As Object

Dim WholeLine As String
Set fs = CreateObject("Scripting.FileSystemObject")
Set ws = Worksheets("Sheet1")
Shell ("C:\windows\system32\cmd /k net user " & Environ("username") &
" > C:\test.txt")

Do
Loop Until fs.fileexists("D:\test.txt")
Open "C:\test.txt" For Input Access Read As #1

Do Until InStr(1, WholeLine, "Local Group Memberships")
Line Input #1, WholeLine
Loop
ws.Range("A1").Value = Trim(Split(WholeLine, "*")(1))
Close #1
fs.deleteFile "C:\test.txt"

End Sub


--


Gary Keramidas
Excel 2003


"ajm1949" <ajm1949(a)discussions.microsoft.com> wrote in message
news:A1E58164-3D47-4BEA-A402-6BC09D12A661(a)microsoft.com...
> How can I determine if a user is logged in as an Administrator or as a
> standard user without Admin priveleges

From: Peter T on
Private Declare Function IsUserAnAdmin Lib "Shell32" () As Boolean

Sub test()

MsgBox IsUserAnAdmin

End Sub

Revert back if the API is ever likely to be used in W9x as it needs an Alias

This doesn't confirm in the UAC is on/off of course

Regards,
Peter T

"ajm1949" <ajm1949(a)discussions.microsoft.com> wrote in message
news:A1E58164-3D47-4BEA-A402-6BC09D12A661(a)microsoft.com...
> How can I determine if a user is logged in as an Administrator or as a
> standard user without Admin priveleges


From: Peter T on
Guess this is a typo
> Loop Until fs.fileexists("D:\test.txt")
should read
Loop Until fs.fileexists("C:\test.txt")

If doing this in Vista or W7 probably won't be able to save to the root, try
somehting like

sFile = application.defaultfilepath & "\userinfo.txt"

Regards,
Peter T


"Gary Keramidas" <gkeramidas(a)MSN.com> wrote in message
news:OhickuNxKHA.6020(a)TK2MSFTNGP06.phx.gbl...
> one other thing i forgot to mention, it uses the D Drive, if you don't
> have one, here's one that will work with the C Drive
>
> Sub test2()
> Dim ws As Worksheet
> Dim fs As Object
>
> Dim WholeLine As String
> Set fs = CreateObject("Scripting.FileSystemObject")
> Set ws = Worksheets("Sheet1")
> Shell ("C:\windows\system32\cmd /k net user " & Environ("username") &
> " > C:\test.txt")
>
> Do
> Loop Until fs.fileexists("D:\test.txt")
> Open "C:\test.txt" For Input Access Read As #1
>
> Do Until InStr(1, WholeLine, "Local Group Memberships")
> Line Input #1, WholeLine
> Loop
> ws.Range("A1").Value = Trim(Split(WholeLine, "*")(1))
> Close #1
> fs.deleteFile "C:\test.txt"
>
> End Sub
>
>
> --
>
>
> Gary Keramidas
> Excel 2003
>
>
> "ajm1949" <ajm1949(a)discussions.microsoft.com> wrote in message
> news:A1E58164-3D47-4BEA-A402-6BC09D12A661(a)microsoft.com...
>> How can I determine if a user is logged in as an Administrator or as a
>> standard user without Admin priveleges
>