Re: script won't run automatically at logon

From: Al Dunbar [MS-MVP] (alan-no-drub-spam_at_hotmail.com)
Date: 05/25/04


Date: Mon, 24 May 2004 20:03:26 -0600

Good questions, all...

"guggsyk" <anonymous@discussions.microsoft.com> wrote in message
news:1181501c441c7$cc9216c0$a001280a@phx.gbl...
> in the logon script field, i've specified:
> \\servername\netlogon\loscript.vbs

I see two completely different issues with this:

1) as I said before, a windows 98 client will be unable to run a vbscript
logon script file directly - more on this below.

2) I assume that "servername" is the actual name of an actual server,
presumably a domain controller. I have never tried specifying a full UNC
path like this. Assuming you have more than one domain controller, you can
get the logon script to be run from the same DC that the user has just
authenticated against by specifying just the name of the script file. If no
absolute path is given the domain controller will find the script relative
to its own NETLOGON share. I strongly recommend that you try it this way, as
that will spread the script processing over all your domain controllers,
people will be able to run the logon script even if that one particular
domain controller is off-line, and it will most likely use the nearest one
for each session.

(oops - just re-read your earlier post and see you have only a single domain
controller. I still recommend that you NOT specify the full UNC, as you
might one day add another server)

> how would i go about using a batch file which in turn
> would run wscript to run the vbscript?

In your case above, I would replace the logon script setting with something
like "loscript.bat". ("loscript.cmd" would not work on a windows 98 client).

Then you create a file by that name in the "scripts" share on the primary
domain controller or primary domain controller emulator, from which it will
replicate to the netlogon share of all domain controllers. If your domain is
fully AD and with no NT4 server infrastructure remaining, it might be that
you would create this file in the netlogon share on any domain controller,
and it would replicate from there to the other domain controllers. (oops
again)

The file itself would simply contain the batch command needed to run the
vbscript file, and could be something like:

    @echo off
    cscript.exe //nologo %0\..\loscript.vbs

This would run your script in the same console window that the batch file
ran in, and you could use wscript.echo to display information there. I
expect, however, that your existing vbscript is generally run by wscript,
and that no console window ever appears. You could change the above to use
wscript instead of cscript, however you might wind up considering this
instead:

    @echo off
    start /wait cscript.exe //nologo %0\..\loscript.vbs

More on this below.

BTW, the %0\..\ prefix specifies the absolute path to the vbscript in the
same folder location as the .bat file. On a windows 98 client, this will be
based on the temporary mapping of the Z: drive to the netlogon share, on
XP/2K/NT it will be based on the UNC of the batch file, including the name
of the participating domain controller.

> am i supposed to keep both batch file & vbscript in the
> netlogon folder?

Yes, that is the best.

> do i have to specify the batch file in each user's "logon
> script" field?

That is the simplest, unless you know for a fact that all users use 98
exclusively or avoid it completely. More on this later.

> would i have to preceed the vbscript name (in the batch
> file) with a command to make it run?

An excellent question, answered above.

> i'm completely clueless at this point. if u could direct
> me to some examples, i'd be very grateful.

Believe me, you are not clueless, you just haven't had a chance to work this
all out for yourself yet. ;-)

> thanx again in advance

You are welcome, again. Now here is the "more" I mentioned a few times
above.

If you created the vbscript to run "invisibly" (i.e. with no console
window), then you might not like the batch console window being there. Users
can cancel it, for one thing, and even if they don't, if they are not used
to it they will wonder what is going on.

On the positive side, it can be easier to test a script by throwing in a
couple of wscript.echo statements at critical points. Our script runs that
way and displays the success (or failure) of anything it might happen to try
to do, like map a network share. This is mainly to indicate to the user that
something is actually happening, not so they will know what is going wrong,
as they sometimes don't seem to understand that an error message means
something has gone wrong ;-) For this reason, our script also creates a more
detailed, time-stamped log file on the workstation that we can refer to
later if there are problems.

I would recommend that, whatever you do, every user be assigned exactly the
same logon script. That will simplify the maintenance of your scripts, as
well as the trouble-shooting when a user has a problem. Unfortunately, this
means having to write the script to the lowest common denominator platform,
and dealing with a few potential headaches...

The vbscript parts are generally not a problem, assuming they are written to
recognize some of the differences between windows versions. Use the
specialfolders method of the shell object rather than hard-coded pathnames
for things like the temp folder, desktop, start menu, and so on. One
problem, though, is that the .username and .computername properties of the
network object are, frustratingly, NOT resolved on a windows 98 system
until, and get this, the logon script has completed!

Simple batch code is generally not a problem, however there are a few
differences you want to be aware of. One is that, if you use the start
command (more on that later) the syntax is different if the command to be
run is given with a path in double-quotes. On XP and other WinNT variants,
it requires a double-quoted window title to precede the double-quoted
program pathname. Anything you can do to keep the batch part of your logon
script to a minimum will be time well spent in making it easier to get
right.

So, why use the START command to run wscript? Depends. Do you want your
users to have access to their desktops before the logon scripts have
completed (asynchronous scripts) or not (synchronous). If you want them to
be blocked from the desktop until the script completes, you will need the
START/wait, as the system will assume the logon script has completed when
"loscript.bat" has quit. PLEASE NOTE, however, that if you use START/wait,
your vbscript will need to find some way to determine the username other
than using the network object (as noted above).

Finally (finally!) here is a suggestion to help you get a handle on this.
Create a test batch script containing the commands below, set that as the
logon script for a test account, and then logon using that test account at a
variety of client platforms in different subnets. This batch file should
help you determine some of the windows platform differences that might cause
you problems if you didn't know.

    @echo off
    echo/testing logon script on windows version:
    VER
    echo/if windows 98, Z: should be mapped to
    echo/netlogon on the participating domain controller.
    echo/check this out:
    NET USE
    echo/the "current directory" might be different from
    echo/system to system:
    CD
    echo/the zeroth batch parameter should be the fully
    echo/qualified path name of the logon script. Is it
    echo/enclosed in double quotes on this client?
    ECHO/[%0]
    pause

Good luck with this stuff. And remember, if you need assistance with batch
scripting, this is a good place for that as well.

/Al

>
>
> >-----Original Message-----
> >
> >"guggsyk" <anonymous@discussions.microsoft.com> wrote in
> message
> >news:1113f01c44151$32f9e1d0$a101280a@phx.gbl...
> >> thank you all for your help, and thank you Al Dunbar for
> >> pointing me in the right direction.
> >>
> >> my script is now working on the win98 computers,
> however,
> >> it still won't run automatically at log in... it has to
> >> be run manually.
> >>
> >> how can i get the script to run automatically when
> >> logging on to the server?
> >>
> >> it's a server 2003 standard edition (active directory &
> >> domain controller with no other servers on the network),
> >> and the script is placed in the netlogon folder. win xp
> >> pro clients see the script & run it automatically
> without
> >> problem, but win98 clients will not run it
> automatically.
> >>
> >> i've tried putting the path to the logon script in the
> >> user's properties in the logon script field (on the
> >> profile tab), but that has not worked either.
> >
> >
> >What, exactly, did you specify as the path to the logon
> script in the user's
> >logon script field?
> >
> >> do i need to make registry entries on each individual
> >> win98 client?
> >
> >No. Definitely not.
> >
> >> shouldn't the win98 clients automatically run the logon
> >> script from the netlogon folder as do the win xp pro
> >> clients?
> >
> >That would be the idea, however, you should be aware that
> win98 clients will
> >not run a vbscript.vbs script directly. Typically you
> need to set the logon
> >script to run a batch file that, in turn, runs cscript or
> wscript to run the
> >vbscript.
> >
> >/Al
> >
> >
> >.
> >



Relevant Pages


Loading