Wouldn't you know right after I posted I found a snippet of code that did the trick, ideas on anything to make this smoother though would be nice:
Set oShell = CreateObject("Wscript.Shell")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\"...
Here is what I have, it works great if you remove the attempt to setup the if statement, but as windows 2000 and xp SP1 do not have powercfg I have to find a way to limit which version of windows this runs on. I am still in a position of no formal training in vb so I am just hacking this out...
AH ha got it all together now and sorry about the mess:
'| /p:newPass4LocalAdministrator
Set objNetwork = WScript.CreateObject("WScript.Network")
sUser = objNetwork.UserName
VerifyGroupMembers = False
Set objGroup = GetObject("WinNT://./Administrators,group")
For Each...
I went this route:
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Dim l As Long
Dim sUser As String
sUser = Space$(255)
l = GetUserName(sUser, 255)
'strip null terminator
If l <> 0 Then
GetCurrentUserName =...
I wanted to document the proper usage of the variable for future is all. I was able to get this working correctly, some people got irritated because they did not have local admin rights so it threw up all over them. So does any know a way of checking "Am I a member of local administrators?
Haveing never worked with VB, but having perl and java exp I tried my hand at a script to change the local password on machine I came up with this:
'| /p:newPass4LocalAdministrator
Option Explicit: Dim Named, sPasswrdAdmin, oUser
Set Named = WScript.Arguments.Named
sPasswrdAdmin =...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.