|
Answer» 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 ... Code: [SELECT]Set objComputer = GetObject("WinNT://" & strComputer & "") But I have no idea how to fix it to work with Windows 7. It does work on XP.
Code: [Select]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 IfIf you are using a 64-bit version of windows you cannot use CreateObject() or GetObject() to create or acquire instances of COM objects.
I had a very similar problem.
My solution was to use the 32-bit version of wscript or cscript, found in %systemroot%\syswow64\
Awesome ...
~bows down to your greatness~ Thanks for the HELP.
|