Sign in to follow this  
Followers 0
AntiVirusGuy

truncate entry computer rename

8 posts in this topic

We have found that if you name your computer with to long of a name you get a lsass error

how can I take this great renaming script and truncate it if the entry is to long. Also note we put a -ws on the end of their username to indicate they are a work startion. Also does anyone no the maximum characters before you get that lsasss error? Thank you everyone in advanced

$cname = FileOpen(@WindowsDir & "\computername.txt", 1)

FileWriteLine($cname, "computer name = " & @ComputerName & " Date = " & @year & "-" & @mon & "-" & @mday)

FileClose(@WindowsDir & "\computername.txt")

$NewSystemName=InputBox ( "Change Computer's Network Name", "Your computer's network name will contain your CSC username." & @CRLF & @CRLF & "Please enter your assigned CSC username followed by a _98 or _ME depending on your Operating System ")

;back up ucomputername add if then statement

If @Error = 1 Then

Exit

Else

RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName", "ComputerName","REG_SZ", $NewSystemName)

RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName", "ComputerName", "REG_SZ", $NewSystemName)

RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "Hostname", "REG_SZ", $NewSystemName)

RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "NV Hostname", "REG_SZ", $NewSystemName)

MsgBox(0,"Computer's New Network Name", "Computer's network name changed to: " & @ComputerName)

EndIf

Exit

Share this post


Link to post
Share on other sites



There are also characters and spaces that are not allowed in the computer name too to consider, I did some messing about renaming a comuter this way and it all worked but just not on the network, you should find out the illegal characters too and check to make sure they havent been entered

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

There are also characters and spaces that are not allowed in the computer name too...

Good luck finding out which characters are considered illegal. This website offers this tidbit of info:

http://www.windowsitlibrary.com/Content/329/02/5.html

Secret: Be advised that your computer name will affect other Microsoft BackOffice applications. For example, the hyphen (-) character is an illegal character in a machine name when working with SQL Server, but such a character isnt illegal natively inside of Windows NT Server. Computer names that contain a hyphen and run SQL Server will not be able to participate in replication or multiserver operations.

Okay, so you might want to stay away from hyphens - but alas, this site

http://download.microsoft.com/download/6/c...ab/relnotes.txt states that any underscore character will be converted to the hyphen character when installing the iSCSI Initiator.

If the Windows computer name contains a character that would be invalid within an iSCSI node name, such as '_', then the Microsoft iSCSI Initiator service will convert the invalid character to '-'.

[but you probably won't have too many end-users installing that SW.]

The OS might accept the @ character as part of the computer name, but Frontpage within Office 97 does not like it. http://support.microsoft.com/kb/q156909/ That page also states:

If you attempt to name computer running Windows NT 4.0 with a restricted character, you receive an error message that indicates that your computer name will not be accessible via internet protocols and will create a substition [substitution]of a "-" character for every unacceptable character.

There is that nasty hyphen again.

As for the maximum characters before you get that lsass.exe error? Ive not encountered this and could find no reference to it online. You should be safe at 15 characters.... just which ones?

http://www.windowsitlibrary.com/Content/329/06/3.html

In the DNS dialog box, you may enter the computer name in the Host Name field. This is an optional entry and may be any name you like as long as illegal characters arent used. To be brutally honest, this is by default the NetBIOS name of the computer, but it can be any name consisting of letters AZ, numbers 09, the hyphen (-), and the period (.).

But W95 probably cannot locate a system with a period in the name.

have fun

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I am not concerned about special charachers If you look at my script it states for users to put in their username. We had 1000 people use this script and it worked great except for about 15 who had usernames to long. Can anyone tell me how to truncate the entry Edited by ssebrownatcolby

Share this post


Link to post
Share on other sites

I am not concerned about special charachers If you look at my script it states for users to put in their username. We had 1000 people use this script and it worked great except for about 15 who had usernames to long. Can anyone tell me how to truncate the entry

I can tell you how to make your text smaller

I'm sure you meant to say thanks but I am not concerned... etc etc

Share this post


Link to post
Share on other sites

If StringLen($NewSystemName) > 15 Then
    $TempSystemName = StringLeft($NewSystemName, 12)
    $OStag = StringRight($NewSystemName, 3)
    $NewSystemName = $TempSystemName & $OStag
EndIf


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Thank you much your help is appreciated

Share this post


Link to post
Share on other sites

You probably would like to tell the user if their username was truncated rather than just go and do it, and give them the choice of doing it correctly with another try.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0