AntiVirusGuy Posted November 19, 2005 Share Posted November 19, 2005 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 Link to comment Share on other sites More sharing options...
ChrisL Posted November 19, 2005 Share Posted November 19, 2005 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 [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
herewasplato Posted November 19, 2005 Share Posted November 19, 2005 (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.htmlSecret: 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.htmlIn 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 November 19, 2005 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
AntiVirusGuy Posted November 20, 2005 Author Share Posted November 20, 2005 (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 November 20, 2005 by ssebrownatcolby Link to comment Share on other sites More sharing options...
ChrisL Posted November 20, 2005 Share Posted November 20, 2005 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 entryI can tell you how to make your text smaller I'm sure you meant to say thanks but I am not concerned... etc etc [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
herewasplato Posted November 20, 2005 Share Posted November 20, 2005 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] Link to comment Share on other sites More sharing options...
AntiVirusGuy Posted November 22, 2005 Author Share Posted November 22, 2005 Thank you much your help is appreciated Link to comment Share on other sites More sharing options...
Confuzzled Posted November 22, 2005 Share Posted November 22, 2005 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now