Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to set username appearing after CTRL+ALT+DELETE

Status
Not open for further replies.
Jun 1, 2005
87
I am trying to create a script that you can run when you've logged on as an administrator, in which you can input a name to show up at the next logon.

For example, say that the user bsmith was last to log on before I came in and logged in under the domain admin account. I am afraid bsmith may have trouble getting logged into their account when they return as they are not likely to notice it says "administrator" in the username field rather than "bsmith." I would like to run this script before I log off or restart so that when they press CTRL+ALT+DELETE it will say "bsmith" instead of "administrator."

I know there is a way to do this because another company I worked at had this script but I am having trouble finding anything similar.

Thanks!
 
i am sure you will find there is a registry setting that you can update. its the ones you use if you want to set an autoadminlogon (gasp). i think most people have the 'display last logged on user at logon prompt' disabled these days through GPO for security reasons?
 
a bit too much...



Dim WshShell, FSO, str2Run
Dim strUserName, strPassword, strDomain, strUserDom

Set WshShell = CreateObject("Wscript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")

strUserName = ""
strPassword = ""
strDomain = ""

If Wscript.Arguments.Count = 3 Then
str2Run = WshShell.ExpandEnvironmentStrings(Wscript.Arguments.Item(0))
strUserDom = Wscript.Arguments.Item(1)
strPassword = Wscript.Arguments.Item(2)
Else
intReturn = 1
End If

If InStr(strUserDom, "\") Then
strDomain = Left(strUserDom, InStr(strUserDom, "\") - 1)
strUserName = Right(strUserDom, Len(strUserDom) - InStrRev(strUserDom, "\"))
Else
strUserName = strUserDom
strDomain = WshShell.ExpandEnvironmentStrings("%computername%")
End If

If str2Run <> "" And strUserName <> "" And strPassword <> "" And strDomain <> "" Then
If FSO.FileExists(str2Run) Then
Wscript.Echo "wroite to reg"
WshShell.RegWrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon", "1", "REG_SZ"
WshShell.RegWrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName", Trim(strDomain), "REG_SZ"
WshShell.RegWrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword", Trim(strPassword), "REG_SZ"
WshShell.RegWrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName", Trim(strUserName), "REG_SZ"

'set a runonce key
WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\instserv", Chr(34) & str2Run & Chr(34), "REG_SZ"
Else
intReturn = 2
End If
Else
intReturn = 1
End If
 
The previous script I used had a box that would pop up so that you could enter the logon name you wanted to show up at the next logon...what do I need to change to allow the script to do that?
 
the script takes commnad line parameters for the username and password.
you would want to get rid of all that and you would only want to write the 'DefaultUserName' registry.
so, woudl be as simple as@

Set WshShell = CreateObject("Wscript.Shell")
str2Write = InputBox("please enter user name")
WshShell.RegWrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName", Trim(str2Write), "REG_SZ"
Set WshShell = Nothing
 
Forgive me, I haven't worked with scripts so I'm a little slow in that regard...where to I put the:

Set WshShell = CreateObject("Wscript.Shell")
str2Write = InputBox("please enter user name")
WshShell.RegWrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName", Trim(str2Write), "REG_SZ"
Set WshShell = Nothing

??
 
put it into a file with an extension of .vbs, double click on it and it will prompt you for some information. put the info in, click ok, then open up the registry and it shoudl have updated it with the information you supplied. this 'might' achieve what you want
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top