Page 1 of 1 1
Topic Options
#206481 - 2012-12-13 09:17 PM Issue with @Domain variable
Robdutoit Offline

Registered: 2012-03-27
Posts: 316
Loc: London, England
Yes its me again. Twice in one day ! But I know you guys love me \:\)

I will be back at the client tomorrow and do some more digging up on the issue, but I thought that I would see if anyone else has had this issue before!

With my shiny new script, I have already setup three networks and I am on my fourth network upgrade which consists of a new software image using WDS and so on. The first two networks were brand new servers, the second network, was a pre-existing Windows 2008 server and this network is also a pre-existing windows 2008 server. I mention this specifically, because I do believe the problem is some missed setting somewhere on this server.

With the first three networks, the @domain function works flawlessly and the script works as expected although I am modifying it almost weekly to take into account differences on each new network.

At this client, the @domain function only works perfectly if you logon and manually run the startup script as administrator and the files are copied across correctly from the netlogon location. However, it does not work if you boot up the computer and have the script run in the startup script. It did perfectly on the first three neworks - no problem.

So the problem is not the script, not the fact that its running in the startup location of the GPO and its not the @domain variable as this works on the previous 3 networks.

Hence, the problem must be something about the server at this location. After doing some testing earlier today, and also at home I have determined the following:

The @domain or %userdnsdomain% does not work when run as a startup script.
However if you put in the name of the \\server\netlogon, this works fine in the startup script. So its not NTFS Permissions on the Netlogon folder, which should be using the default permissions anyway.

The @Domain does work if you run the startup script manually while logged on as administrator, so the script syntax is obviously correct and obviously it worked on the other networks.

Also interestingly enough the @domain variable returns the Netbios name, not the FQDN, so I was thinking it was a Netbios issue with this server, but it works when you logon and run the script manually.

so I was just wondering if anyone else has had this issue where the @domain variable works when the script is run manually, but does not work when booting up the computer and running from the startup script. The entire startup script runs when the computer boots - I have tested this by changing registry keys to be the opposite of what the script will change them to and I can see that the startup script is running, because the changes are being made. The only things that are not working is any line with the @domain variable in it. But if you put in \\servername\netlogon the entire script works as should be.

Any idea why the @domain fails on bootup?
I will be hard at working on that server tomorrow, so I will see if I can find any clues to the cause of the problem. as the client computer is freshly imaged, and the script is a new and working script as per the previous three networks that I have just upgraded, my conclusion is some setting on the pre-existing server is somehow interfering with the netbios resolution on bootup?

Thanks in advance for any ideas!

#206486 - 2012-12-14 02:34 PM Re: Issue with @Domain variable [Re: Robdutoit]
Robdutoit Offline

Registered: 2012-03-27
Posts: 316
Loc: London, England
Update on the problem. After much troubleshooting, and screaming at everyone (just kidding), I have unearthed the dear sweet problem
I have put a sleep for 120 in the script and it works perfectly. Aargh - It is obviously running the entire startup script too quickly and hasn't loaded the information for @domain yet.

What can I do to get the startup script to wait for the @domain info to be loaded prior to execution of the script
I have added this to the script, but it does not seem to work, so for the moment I am going to have to use the sleep for 60 seconds option to force the script to wait.

? "Domain name is " @Domain
@Domain = ""
sleep 0.3
? "sleeping for 300 milliseconds"

Hope this helps somebody ele

#206487 - 2012-12-14 03:54 PM Re: Issue with @Domain variable [Re: Robdutoit]
Glenn Barnas Administrator Offline
KiX Supporter

Registered: 2003-01-28
Posts: 4347
Loc: New Jersey
Not likely a script problem..

Make sure that your have a Computer GPO defined that enables "Always wait for the network at computer startup and logon". This has been discussed here several times, along with the "Run logon scripts synchronously", which prevents the dsesktop from displaying before the script completes. Without the former setting, the login process will start before all network services are ready.

I include these policies at every client site and never have these kind of issues once they are in place.

Actually I am a Rocket Scientist! \:D

#206488 - 2012-12-14 04:03 PM Re: Issue with @Domain variable [Re: Glenn Barnas]
Les Offline
KiX Master

Registered: 2001-06-11
Posts: 12734
I think the OP has a GPO aversion.
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

#206493 - 2012-12-14 08:05 PM Re: Issue with @Domain variable [Re: Les]
Robdutoit Offline

Registered: 2012-03-27
Posts: 316
Loc: London, England
the man mocks me! GPO is just slow. I like a fast network. I will see if I can find a solution to the problem without having to resort to always wait for network as that defeats part of the object of the network upgrade, which is to improve login time. cheers
#206494 - 2012-12-14 11:38 PM Re: Issue with @Domain variable [Re: Robdutoit]
ShaneEP Moderator Offline
MM club member

Registered: 2002-11-29
Posts: 2092
Loc: Tulsa, OK
You could create your own "wait for network" loop like so...

While not OSping("")
  ? "looping"

Function OSping($sComputer, OPTIONAL $timeout)
   $timeout = IIf(Len($timeout),$timeout,500)
   Shell '"'+%COMSPEC%+'" /c ping -n 1 -w '+$timeout+' '+$sComputer+' |find /C "TTL=" >nul'
   $OSping = not @ERROR

Page 1 of 1 1

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

Who's Online
0 registered and 132 anonymous users online.
Newest Members
multiman, simonedsouza, amarawatt, harry_hs, johnjorge
17730 Registered Users

Generated in 0.033 seconds in which 0.012 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google: