Would anyone know how to make this work on Windows 7? Running the Script with admin rights doesn't work at least not in my testing. Start CMD in admin mode and then ran the vbs file from that CMD windows and it returns not admin. I'm half thinking it has something to do with this line ... Set objComputer = GetObject("WinNT://" & strComputer & "")
But I have no idea how to fix it to work with Windows 7. It does work on XP.
On Error Resume Next
strTestUser = "TestUser"
strComputer = "."
Set objComputer = GetObject("WinNT://" & strComputer & "")
'Try to create test account
Set objUser = objComputer.Create("user", strTestUser)
objUser.SetPassword "blahblah"
objUser.SetInfo
'WScript.Echo Err.Number
If Err.Number <> 0 Then
WScript.Echo "Not an admin"
Else
WScript.Echo "Is an admin"
'Cleanup test account
objComputer.Delete "user", strTestUser
End If