Page 1 of 2 12>
Topic Options
#30033 - 2002-10-01 09:07 PM Trouble with LMHOSTS
Tony72 Offline
Getting the hang of it

Registered: 2002-06-18
Posts: 53
Where I work we are having a lot of problems with Netbios name resolution. I personally believe that there are issues with the switches (we didnt have these problems before they went in), but since we outsource the hubs/routers/switches, I cant fix it and the people managing it havent done anything. But I digress.

My problems seem to be, for the most part, with WinNT OSs (NT/2k). I tried using the Kixtart "copy" command to copy the file from the netlogon directory to @LanRoot\drivers\etc\, but it didnt work and exited with an error code 2 (?). I couldnt find any information on what copy meant by error 2, so I tried to work around it.

so now, Im trying to use the shell and rename lmhosts.10 to lmhosts. I must be a complete doofus, because I cannot get it to work no matter what I do. Here is what I am trying to use (the variables come from elsewhere. I wrote it so I could have one script for multiple sites).

code:
 
$LMHostsPath = "@LanRoot\drivers\etc\"
$LMH = "$LMHostsPath" + "lmhosts."
$num = 10
$string = "%comspec% /c ren $LMH$num $LMH"
shell $string

This gives an error of "The syntaxt of the command is incorrect." So what exactly am I doing wrong?

also, is there a better way of doing this? I've seen people people discuss this problem, but no real resolutions.

Lastly, has anyone used Scriptlogic? I saw an ad and was checking it out, but wanted to know if its as flexible as kixtart.
_________________________
Be kind; each person is fighting his own private war.

Top
#30034 - 2002-10-01 09:10 PM Re: Trouble with LMHOSTS
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
take out the .
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#30035 - 2002-10-01 09:53 PM Re: Trouble with LMHOSTS
Tony72 Offline
Getting the hang of it

Registered: 2002-06-18
Posts: 53
No, that doesnt do it. I knew it wouldnt; if you have a . there it will specify a file; sometimes it can get weird if you have a file and folder in the same directory with the same name, and the . helps you avoid problems.

As a side note, if you want a listing of all files without suffixes, you can do "dir *."

Anyway, I tried it just for fun and received the exact same error.
_________________________
Be kind; each person is fighting his own private war.

Top
#30036 - 2002-10-01 10:02 PM Re: Trouble with LMHOSTS
badboii Offline
Fresh Scripter

Registered: 2002-03-07
Posts: 32
Loc: Seattle, WA
Hey Tony,

Not sure if Radimus solved your problem but here's what I do to help with name resolution.

code:
;***** Delete old lmhosts files and copy the new
If %OS% = "Windows_NT"
Del "%SystemRoot%\System32\Drivers\Etc\lmhosts.sam"
Del "%SystemRoot%\System32\Drivers\Etc\hosts"
Copy "\\FILESERVER\NETLOGON\LMHOSTS" "%SystemRoot%\System32\Drivers\Etc\"
Shell "nbtstat -R"
Shell "nbtstat -r"
Else
Del "C:\WINDOWS\LMHOSTS"
Del "C:\WINDOWS\HOSTS"
EndIf

_________________________
========================== Brian Zamora Computer Technician brian_zamora@hotmail.com ==========================

Top
#30037 - 2002-10-01 10:06 PM Re: Trouble with LMHOSTS
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Try this and take a look at the paths
code:
$LMHostsPath = "@LanRoot\drivers\etc\"
$LMH = "$LMHostsPath" + "lmhosts."
$num = 10
$string = "%comspec% /c ren $LMH$num $LMH"
? 'Executing '+$string
shell $string



[ 01. October 2002, 22:15: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#30038 - 2002-10-01 10:26 PM Re: Trouble with LMHOSTS
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You cannot specify the drive and path on the destination, only the name.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#30039 - 2002-10-01 10:43 PM Re: Trouble with LMHOSTS
Tony72 Offline
Getting the hang of it

Registered: 2002-06-18
Posts: 53
I tried something like that before, but ? had a problem displaying %comspec%. I didnt feel like using ExpandEnvironmentVars, so I didnt get into it (remember, when you drop to shell you are using a different environment).

What I did test was
code:
 
$LMHostsPath = "@LanRoot\drivers\etc\"
$LMH = "$LMHostsPath" + "lmhosts."
$num = 10
? "/c ren $LMH$num $LMH"

which displayed correctly. I suppose if I had a real woody for it I could have used the shell and had it echo... which I will try now that I thought of it.

Also, does anyone know what went wrong with using Kixtart's copy command? This is what exited with error code 2-

code:
 
:COPYLMH
$LMH = "$LMHostsPath" + "lmhosts."
Select
Case "$Loc" = "DePaul" copy "lmhosts.10" "$LMH" /h
Case "$Loc" = "Lexington" copy "lmhosts.10" "$LMH" /h
Case 1 copy "lmhosts.167" "$LMH" /h
EndSelect
Return

_________________________
Be kind; each person is fighting his own private war.

Top
#30040 - 2002-10-02 04:17 AM Re: Trouble with LMHOSTS
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Did you understand my post? Have you factored that users may not have the rights to copy and/or rename in etc?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#30041 - 2002-10-02 06:37 AM Re: Trouble with LMHOSTS
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Tony72,

Les brings up a great point..

Most people cannot write to directories (folders) below Windows or Winnt.. For example, they may not be able to change files at System32\Drivers\etc..

Personally, I came across an issue with our locked down users, that they cannot write to Windows/Winnt itself. This prompted me to create a $systemdrive+"\Scripts" folder.

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#30042 - 2002-10-02 03:07 PM Re: Trouble with LMHOSTS
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
As a rule of thumb, anything done under %WINDIR% requires administrative privileges by default under Windows NT/2000/XP. This might be a simplification but it normally alleviates a lot of problems.

Ths was actually what prompted me to come up with KSMS since I wanted to do only the most basic stuff from within a loginscript and move anything else that is computer-management-related into a separate script.

[ 02. October 2002, 15:09: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#30043 - 2002-10-02 03:09 PM Re: Trouble with LMHOSTS
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yeh... still, I'd change the var in your text.
not always under windir is needed rights.
only under %systemroot%
_________________________
!

download KiXnet

Top
#30044 - 2002-10-02 03:14 PM Re: Trouble with LMHOSTS
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
[Confused]
%SYSTEMNROOT% = C:\
%WINDIR% = C:\WINT

in default installations. I did mean the directory that Windows itself is installed into, which by default is C:\WINNT unless the folder has been renamed or moved to another partition during installation. Of course, YMMV.
_________________________
There are two types of vessels, submarines and targets.

Top
#30045 - 2002-10-02 04:05 PM Re: Trouble with LMHOSTS
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Better maybe, to use the INCLUDE option to centrally managed LMHOSTS files.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#30046 - 2002-10-02 05:22 PM Re: Trouble with LMHOSTS
Tony72 Offline
Getting the hang of it

Registered: 2002-06-18
Posts: 53
1. its not a rights issue (at least not at this point), because I am testing it under an administrator account. The only errors are with either syntaxt (which APPEARS correct, at least to me), or with Kixtart itself (?!). I would guess it is the former, but the latter is possible.

2. I would like to have an INCLUDE in the LMHOSTS, but since I cannot actually replace or push the file, it becomes a moot point. Unfortunately, it seems the only solution may come by either having kix make a stub file that is used by kixtart.bat at next logon, or doing it by hand (*gasp!*)

[ 02. October 2002, 17:22: Message edited by: Tony72 ]
_________________________
Be kind; each person is fighting his own private war.

Top
#30047 - 2002-10-02 05:28 PM Re: Trouble with LMHOSTS
Tony72 Offline
Getting the hang of it

Registered: 2002-06-18
Posts: 53
oh ya, I forgot to mention: the purpose of this whole thing is because we are switching PDCs. So we need this done before they are switched, or else the Win2000 machines wont be able to log on.

Win2k, on an NT4 network, will only authenticate to the PDC unless it has an LMHOSTS file that explicitly tells it the locations of other Domain Controllers. You also cannot add the machine to the domain unless it knows where the PDC is, and the before mentioned NetBIOS problem is prohibiting that currently. So any Win2k machines that are not at this site need to have an LMHOSTS file.

[ 02. October 2002, 17:31: Message edited by: Tony72 ]
_________________________
Be kind; each person is fighting his own private war.

Top
#30048 - 2002-10-02 05:49 PM Re: Trouble with LMHOSTS
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
So... bring us up to speed... what do you have now? What doesn't work?

When I took the drive and path out of the destination in your first example it worked in my tests. Have you tried without the drive and path on the destination (I ask again)?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#30049 - 2002-10-02 05:58 PM Re: Trouble with LMHOSTS
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Maybe I didn't make myself clear...
Maybe you slept through DOS101...

THe syntax for the DOS REN command is as follows:
quote:
C:\>ren /?
Renames a file or files.

RENAME [drive:][path]filename1 filename2.
REN [drive:][path]filename1 filename2.

Note that you cannot specify a new drive or path for your destination file.

C:\>

So then...
$string = "%comspec% /c ren $LMH$num $LMH"

should be...
$string = "%comspec% /c ren $LMH$num lmhosts"
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#30050 - 2002-10-02 06:17 PM Re: Trouble with LMHOSTS
Tony72 Offline
Getting the hang of it

Registered: 2002-06-18
Posts: 53
You know, there are ways of saying things without being an @$$hole. But I will try your suggestion.
_________________________
Be kind; each person is fighting his own private war.

Top
#30051 - 2002-10-02 06:29 PM Re: Trouble with LMHOSTS
Tony72 Offline
Getting the hang of it

Registered: 2002-06-18
Posts: 53
Thanks, it worked. To answer your two questions-

1. No, you did not make yourself clear
2. No, I did not sleep thru DOS101

I actaully had been working on this problem for a very long time, and using REN was not my first option (or attempt) at doing this specific task. So pardon me, but at this point my mind is kind of burnt out. I dont run to the message board every time I have a little problem, this option is when I truly need the help.

So thanks for your help, but you should enroll in MANNERS101.
_________________________
Be kind; each person is fighting his own private war.

Top
#30052 - 2002-10-02 06:38 PM Re: Trouble with LMHOSTS
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... you're not the first person to call me that and yes I've been sent to manners school more than once.

Figured that I wasn't making myself clear so thought a poke might get your attention. I see it has.

Glad things worked out for you. If you need any further help (or abuse) you know where to look.

[ 02. October 2002, 18:39: Message edited by: LLigetfa ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 595 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.071 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org