I'm attempting to re-write a script to change the last logged on user using a previous script as below:
'--------------
'Start of UAC workaround code
If WScript.Arguments.length =0 Then
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "wscript.exe", Chr(34) & _
WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1
Else
'--------------
'Start of code
dim WSHShell
Set WSHShell = Wscript.CreateObject("WScript.Shell")
dim strRegKey
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
strRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\"
StrUser = InputBox("Please enter in username," & vbCrLf & vbCrLf & "e.g. joe.local", "Set Last logged on", "UserName")
StrDomain = InputBox("Please enter in domain for logon," & vbCrLf & vbCrLf & "e.g. DOMAIN", "Set Logon Domain OR leave blank if a local user account", "Domain.local")
If StrDomain = "" then
StrDomain = "."
Else
End If
wshShell.RegWrite strRegKey & "LastLoggedOnUser", StrDomain & "\" & StrUser, "REG_SZ"
wshShell.RegWrite strRegKey & "LastLoggedOnSAMUser", StrDomain & "\" & StrUser, "REG_SZ"
WScript.Echo "Setup Completed. Please restart the computer to complete the process
'--------------
'End of code
'--------------
'End of UAC workaround code
I need to use the StrUser Variable in a couple of wmic queries as Windows 10 needs more information to do the change!:
wmic useraccount where name=StrUser get sid
wmic useraccount where name=StrUser get fullname
The outputs from those queries I want to then apply to a couple of registry keys. I don't know how to pass the variable to the query or capture the result?