×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Script to set username appearing after CTRL+ALT+DELETE

Script to set username appearing after CTRL+ALT+DELETE

Script to set username appearing after CTRL+ALT+DELETE

(OP)
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!

RE: Script to set username appearing after CTRL+ALT+DELETE

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?

RE: Script to set username appearing after CTRL+ALT+DELETE

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

RE: Script to set username appearing after CTRL+ALT+DELETE

(OP)
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?

RE: Script to set username appearing after CTRL+ALT+DELETE

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

RE: Script to set username appearing after CTRL+ALT+DELETE

(OP)
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

??

RE: Script to set username appearing after CTRL+ALT+DELETE

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

RE: Script to set username appearing after CTRL+ALT+DELETE

(OP)
Sweet that works, thanks!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close