Solved: Change Netbios name on login? May the heavens open up on me.

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

StumpedTechy

Thread Starter
Joined
Jul 7, 2004
Messages
7,235
I think I can finally get my bosses approval on using a logon script if i can get this working right!

I found a VBS that will change the netbios user name but will not reset the machine names we use in AD. Below is the script I found at kellyscorner. I think I can modify it to change the netbios name to the current logged in user by taking out the input box and having it scan the registry (or do a user variable somehow) for current logged on user instead.

Option Explicit

Set ws = WScript.CreateObject("WScript.Shell")
Dim ws, t, p1, p2, n, cn, vbdefaultbutton
Dim itemtype

p1 = "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\"

n = ws.RegRead(p1 & "ComputerName")
t = "Change Computer Name"
cn = InputBox("Type new Name and click OK", t, n)
If cn <> "" Then
ws.RegWrite p1 & "ComputerName", cn
End If

The application we use scans active PC's and gives us host name (AD computer name) and Netbios name and Netbios user.

The ONLY problem I am having is that this change does not take place until the next reboot of the machine... This makes it okay for when a user logs in more than once but it will not help with the single login people who sometimes share a PC.

Any thoughts on a way around this? Basically I want to find a way to know who is logged onto what PC without having to look at a report (my boss won't stand to have to look at something to determine where people are) but wants this real time (what may make it so I can finally setup a login script).

Lastly I have a question about the Netbios user field... where does it populate this information from? Half of ours are the same as the Netbios Name but I know they are logging onto the Domain with a different username than whats showing. Another half is showing n/a but they have a netbios name. Since I don't deal with Netbios much I am in the dark and thought I would ask here rather than doing hours of searching.
 
Joined
Nov 28, 2005
Messages
120
There is no such thing as a "NetBIOS user name." The only thing I can think that might be close to what you are thinking of would be the "pre-Windows 2000 username."

So, it appears you're trying to rename the computers on the fly to match the logged-in user's name? (Not sure what this has to do with running a login script, but I'll assume that's a political thing...) You can easily pull the logged in user's name from a few different sources (%USERNAME% is easiest, but you can also find it in HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon User Name among other places), but any change to the computer's name requires a reboot for it to take effect. I don't believe there is any way to change the name on the fly.

Is your objective to rename the PCs just to find out who is logged on where? If so, I would recommend trying a utility like psloggedon instead (http://www.techbytes.ca/techbyte79.html). If you're running NetBIOS you can also sometimes query this information from the command prompt using "nbtstat -a <computername>" (the -a switch is case sensitive).

Lastly I have a question about the Netbios user field... where does it populate this information from?
Again, there's no such thing as a NetBIOS username. The only thing I can think of is the pre-Windows 2000 username which is found on the Account tab of a user's properties window in AD Users and Computers.

Even though the NetBIOS computer name and host name could technically differ, even they are typically the same. Usually the only time I see "NetBIOS name" used is in conjunction with a domain name.
 

StumpedTechy

Thread Starter
Joined
Jul 7, 2004
Messages
7,235
You can easily pull the logged in user's name from a few different sources (%USERNAME% is easiest, but you can also find it in HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon User Name among other places),
Yes I realize that -

but any change to the computer's name requires a reboot for it to take effect. I don't believe there is any way to change the name on the fly.
this is what I am praying to be able to do.

so, I would recommend trying a utility like psloggedon instead (http://www.techbytes.ca/techbyte79.html).
This won't work for us. 1) its not real time and able to scan PC's that are not on (the application we use keeps old information in it so we can pull from it at any time if the PC is turned off we still see the last logged in information) 2) takes too long to scan (we use a ton of subnets and other things) 3) is yet another tool my boss would have to use (see my previous posts on my boss).

If you're running NetBIOS you can also sometimes query this information from the command prompt using "nbtstat -a <computername>"
I realize this but this too does not show the change until reboot.

Again, there's no such thing as a NetBIOS username. The only thing I can think of is the pre-Windows 2000 username which is found on the Account tab of a user's properties window in AD Users and Computers.
No the utility we use (Look@Lan) does not query AD at all so this cannot be where its geting the information from. I had never heard of this before using this tool so I am not quite sure what its about but it is a field given and its pulling information from somwehre because we have 3 different types a - meaning not getting netbios at all blank n/a meaning no name and a name (usually same as the Netbios Name).

So I guess I have to look further to find out where it gets this field from.

Even though the NetBIOS computer name and host name could technically differ, even they are typically the same. Usually the only time I see "NetBIOS name" used is in conjunction with a domain name
I understand this but when I have to make a solution work within a confine of a tool my boss already uses I have to get creative.
 

StumpedTechy

Thread Starter
Joined
Jul 7, 2004
Messages
7,235
It seems this is reporting from -

USER <03> UNIQUE Registered

When I do the same NBTSTAT on the machines this is the only line that is on one that isn't on the other and all that have Netbios User have this line and all that have n/a does not have this line. it must be the Unique <03> that reports this field.

Anyone know how this is modified or filled in?
 
Joined
Nov 28, 2005
Messages
120
The nbtstat was meant as a way to query the username, not the machine name. I guess I just don't understand the reasoning behind having to rename the computers to match the username if you can just query the username directly...

At any rate, a computer rename will not take effect until the computer is rebooted, period. The name is set long before a user can login. I think you're chasing a dream here... :(
 
Joined
Nov 28, 2005
Messages
120
<03> is the Messenger service. Is the Messenger service running on this PC? Is that username logged on in more than one place?
 

StumpedTechy

Thread Starter
Joined
Jul 7, 2004
Messages
7,235
I guess I just don't understand the reasoning behind having to rename the computers to match the username if you can just query the username directly...
Please tell me how to do that without forcing my boss to another tool.

I need to get a machine name associated with the user who has last logged onto it. We need to be able to find this out if the PC is on or off so the tool has to have a way of logging and showing the last logged on information.

What my boss was going to do was going to make us go around to EVERY PC and change the machine name to a User. The problem is PC's move around so much that doing this in AD is rediculous! We would be spending our entire time changing machine names for nothing.

Then I thought to change the Netbios so this way it shows up on our report we would have the hostname (AD) be what we originally setout and the Netbios could be changed (but doesn't without a reboot) so this gets us closer but not "real time"
 

StumpedTechy

Thread Starter
Joined
Jul 7, 2004
Messages
7,235
Hrmmm I just turned on my messanger service and I am now getting my name listed there.... I need to do some checking maybe I just need to enable the messenger service on the other PC's.
 

StumpedTechy

Thread Starter
Joined
Jul 7, 2004
Messages
7,235
Okay I have a breakthrough and a problem!

I am now going to forget the modifying of the Netbios Name, I now am going tyo focus on the messenger service.

If I turn on messenger service it works. I get my name and I get it showing in the application we use... but I have a problem as well. The ones that have it set to Automatic are showing old information in the NBTSTAT until I stop and restart their messenger service it still continues to show wrong information.

I.E. Joan logs into computer A as Joan. Computer A's netbios user or <03> was Ron. It continues to be Ron until a stop and restart the messenger service.

Since the Messenger service is set to be automatic on startup shouldn't this be changing at each log on? Or maybe I can set something into the login to stop and restart this service in the background?
 

StumpedTechy

Thread Starter
Joined
Jul 7, 2004
Messages
7,235
Well we figured it all out.

It wasn't too painful.

@echo off
cls
sc config messenger start= auto
net stop messenger
net start messenger
exit

This will ensure on any machine that it may be disabled for it enables it and it will stop and restart the service on login.

This will do exactly what I need but one thing...

How do you implment a logon script to run hidden?
 
Joined
Nov 28, 2005
Messages
120
"Automatic" startup of a service means it starts automatically when the system starts, not on login. Stopping and starting the service in the login script is a good solution. :) The only thing that may or may not prove problematic: your users will need local admin rights to control the service. Just something to keep in mind.

In Group Policy Editor you can set the visibility of login scripts:
"User Configuration\Administrative Templates\System\Scripts" has a few options. You may be able to set them directly in the registry as well, but I don't know the registry values for these options off hand.
 

StumpedTechy

Thread Starter
Joined
Jul 7, 2004
Messages
7,235
"Automatic" startup of a service means it starts automatically when the system starts, not on login. Stopping and starting the service in the login script is a good solution. The only thing that may or may not prove problematic: your users will need local admin rights to control the service. Just something to keep in mind
No actually this was very easy. I set it to Run in a GPO in Startup - startup does run things as Admin where logon does it as the users permissions (which ours are non administrator). I just moved all the computers to the new OU I made and applied the GPO (we had just had them all in the original Computers OU). Its running currently on our network for the next couple weeks to make sure we get all the PC's.

Thanks for the messenger service information this helped alot in getting this implemented and made for a TON of hours renaming machines manually every tyime someone moved from one PC to another.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Staff online

Members online

Top