Link to home
Start Free TrialLog in
Avatar of mortar
mortar

asked on

Reset Default Username on Logon Screen

Hi, I log on to several different machines in a small office environment and I was wondering if it was possible to reset the "default username" on logon, to the computer's default each time I log out.  I.e. one person most of the time uses just the one machine, so it's easier then changing the last used, and retyping.

For instance:

We have 13 machines, each named client01, client02 etc to client13

Client01 for instance, the main username is joe.bloggs, client02 is john.smith.  If I come along and log on as ITAdmin, when I log out, my username will still be there, but I want to know if it is possible, to reset it back to joe.bloggs if on the client01 machine or john.smith if on the Client02 machine automatically.

I basically have the REG File done up already that changes what I need:
----------------------------------------------------------------------------------
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"DefaultUserName"="joe.bloggs"
"AltDefaultUserName"="joe.bloggs"
"AltDefaultDomainName"="business.domain"
"DefaultDomainName"="business.domain"
"CachePrimaryDomain"="business.domain"
---------------------------------------------------------------------------------- (are all of these lines necessary?)

And i'd assume i'd also keep the central user list on the server somewhere i.e. M:\loginlist.txt

client01;joe.bloggs
client02;john.smith

I can pull the %computername% variable from the OS and validate it using the loginlist.txt file. Is there anyway to feed it into the registry file?
I'd prefer to do it with just the one registry file is possible i.e. "AltDefaultUserName" = %username%

Is this the right way to go about it? Can anyone help me to complete the few remaining steps or show me an easier way to accomplish this?
Avatar of Juan Ocasio
Juan Ocasio
Flag of United States of America image

Usually there really in no way to do this.  You could set a group policy to not show any users (which is more secure that having the last person who logged on displayed).  However, looking at what you are doing, what you could probably do is create a group policy that runs a script on log off that will run a .reg file on the person's machine (tucked somewhere say C:\defaultUser.reg)that way, whenever a user logs off, it will run the script, which in turn will update the registry with the values.  One caveat to this however is the user who is logging off will have to have admin right on the box, otherwise they will not be able to mod the registry.

HTH

jocasio
Avatar of mortar
mortar

ASKER

Admin rights aren't a problem as my username has admin rights to the system, and I only want this process to occur for my username only, and no other usernames.

I've done basically all the steps automatically already up until the point of the registry files, so my solution would work with multiple reg files, I just wanted to know if there was a way to do it just with one, or an easier way to do the whole process.  I don't think group policies will work too well because they're normally for all users aren't they?
ASKER CERTIFIED SOLUTION
Avatar of graye
graye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mortar

ASKER

thanks graye, I'll look forward to it :)
it's there now...
Avatar of mortar

ASKER

Can I compile it as an EXE file for redistribution on another PC as I don't have .Net installed on any of the computers in question..? If so, how?
Let me see if I understand...

Yes, you must have either Visual Studio .Net (you can get a 60-day free trial at http://msdn.microsoft.com/vstudio/productinfo/trial/default.aspx) or the .Net Software Development Kit (http://www.microsoft.com/downloads/details.aspx?FamilyId=9B3A2CA6-3647-4070-9F41-A333C6B9181D&displaylang=en) installed on at least one PC in order to compile the program as an EXE.

In addition to that, all PCs must have the .Net framework installed (but chances are they already have it installed...)

One of the selling points about .Net is that the applications don't need to be installed... the EXE can simply be copied to the local PC via login batch file and run from that local directory.
Avatar of mortar

ASKER

I've got visual studio.net but i'm a Visual Basic 6.0 programmer, so it's all a bit new to me.  I've built the program and tested it using F5, but couldn't find a place to make an EXE file similiar to how you make one using the file menu of Visual Basic 6.0 so I just grabbed it out of the bin folder in the source directory.

Is there any repercussions to installing the .Net Framework? I.e. computer runs slower, takes up too much space, any other problems?
Getting the files from the bin folder is exactly what I do... I hardly ever go to the bother of creating an install package.  There should be 2 or 3 files in there (depending on whether you compiled with the debug option).  All of those files should be copied to the target PCs (we do it with a login batch file)

Most "modern" PCs should already have the .Net Framework by now... it's been available via the microsoft Update site for over 2 years (as an optional component).   Besides, you probably already have .Net applications installed (like Norton Antivirus) and therefore already have the .Net framework

No, I wouldn't expect any issues with installing the .Net Framework v1.1... there are a few security updates after you do an install, so I just tell folks to run the usual Microsoft updates from the web site.

Welcome to the brave new .Net world !

By the way... Microsoft support for VB6 officially ends on 31 March (a week from today)
Avatar of mortar

ASKER

Sorry but still stepping through it.  I installed the framework but receive the following error:

--====---
The application attempted to perform an operation not allowed by the security policy.  The operation required the SecurityException.  To grant this application the required permission please contact your system administrator, or use the Microsoft .NET security policy administration tool.

If you click Continue, the application will ignore this error and attempt to continue.  if you click Quit, the application will be shut down immediately.

Request Failed
--====---

Should I attempt to create a system policy?  This is the only .NET application that I wish to run for the time being.  Will I have to repeat this process for all 13 computers?
I had suggested that you copy the program's files (from the bin directory on your development PC) to each client PC with a login batch file (or some other method).

The .Net framework assigns different security policies to programs that are run locally vs. those that are run via a network share.   So, you essentially have two choices...  copy the files (so that the program is under the "local" security policy) or alter the security policy for the local intranet to allow for the program to run.

The simple solution is to copy the file...   We use something like this in our adminitrator's login batch to 1) copy the files to the local PC if they don't already exist, 2) update the files if they do already exist, 3) run the program

     replace \\someserver\someshare\somepath\UserRestore.* c:\somepath /u
     replace \\someserver\someshare\somepath\UserRestore.* c:\somepath /a
     c:\somepath\UserRestore.exe

BTW: You've got 2 days until the official end of support for VB6.   I wouldn't wait much longer to be starting to learn VB.Net
Avatar of mortar

ASKER

Sorry I forgot your post from the other day.. Makes sense now ;)

Ran it locally and it worked fine!

Thank you very much for your input, fantastic little program.

Keep up the good work, i'll get into VB.Net this weekend!