Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Vista Logon Script

9 views
Skip to first unread message

Richard Mueller

unread,
Nov 22, 2006, 12:19:35 PM11/22/06
to
> I am working with the RTM release of Vista trying to get my organization's
> logon/logoff scripts working. I have found one problem that I need some
> assistance with.
>
> One of our logon scripts maps drives based on group membership. It works
> fine in Vista if it is ran once a user is fully logged in but does not
> work
> when ran via the logon script. I have tried the following things:
>
> - Map the drive using WScript.Network.MapNetworkDrive.
> - Map the drive using "net use".
> - Making the script sleep for 30 seconds before mapping the drives.

Can you post a snippet of your script that duplicates the problem? Also,
does the script run correctly as a logon script on XP or W2k clients?

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net


randyhnewsg...@discussions.microsoft.com

unread,
Nov 22, 2006, 12:34:02 PM11/22/06
to
These scripts work fine with XP. Here is a sample of what doesn't work:

Set WSHNetwork = WScript.CreateObject("WScript.Network")
WSHNetwork.MapNetworkDrive "G:", "\\SERVER\SHARE"

As I said previously the scripts work if I run them after logging on, just
not when run from a logon script.

Thanks,
Randy

Richard Mueller

unread,
Nov 22, 2006, 12:47:28 PM11/22/06
to
Sorry, I haven't worked with Vista yet. Maybe others have. Does it help if
you use?

Set WSHNetwork = CreateObject("WScript.Network")

Perhaps the Wscript object is not allowed. Also, you might try to trap the
error and code something to indicate the error. Perhaps:
=============
On Error Resume Next
Set WSHNetwork = CreateObject("WScript.Network")
If (Err.Number <> 0) Then
Call MsgBox("Error number: " & Err.Number _
"Description: " & Err.Description _
"Source: " & Err.Source)
End If
Err.Clear


WSHNetwork.MapNetworkDrive "G:", "\\SERVER\SHARE"

If (Err.Number <> 0) Then
Call MsgBox("Error number: " & Err.Number _
"Description: " & Err.Description _
"Source: " & Err.Source)
End If
On Error GoTo 0
=========
At least this will give you a clue as to which statement is the problem, and
what the error message might be. The person logging on should see the
message boxes.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net

"ran...@newsgroups.nospam"
<randyhnewsg...@discussions.microsoft.com> wrote in message
news:DCE09B17-D6DF-48DD...@microsoft.com...

Paul Baker [MVP, Windows - Networking]

unread,
Nov 22, 2006, 12:51:57 PM11/22/06
to
Is there a guarantee that the network is up and running when the log in
script is being run? Perhaps Windows XP just got to that point a little
quicker than Windows Vista for you, especially if Vista is taking the idea
of fast boot and login time at the expense of deferred initialization a step
further. FWIW, our login scripts here in this domain map a network drive and
seems to work no problem on Windows XP.

Paul

"ran...@newsgroups.nospam"
<randyhnewsg...@discussions.microsoft.com> wrote in message
news:DCE09B17-D6DF-48DD...@microsoft.com...

randyhnewsg...@discussions.microsoft.com

unread,
Nov 22, 2006, 1:09:02 PM11/22/06
to
The scripts don't error out. Sorry, I forgot to mention that.

I just tried mapping to the same drive twice and the second time I map to it
I get an error stating that the device is already in use. Does that mean the
drives are mapping but for some reason getting disconnected after the script
runs?

randyhnewsg...@discussions.microsoft.com

unread,
Nov 22, 2006, 1:11:01 PM11/22/06
to
The network must be up and running. We have cached credentials disabled and
other scripts that run before the drive mapping scripts query a database and
they are working fine.

t...@advantexmail.net

unread,
Nov 22, 2006, 1:15:18 PM11/22/06
to
I'm glad somebody asked this. This is my exact problem too. I can't
for the life of me figure out what is going on. It works fine on 2K
and XP machines as it has for years, but my first Vista box the script
doesn't work at logon. It will work perfectly when executed after
logon. Please help!


Paul Baker [MVP, Windows - Networking] wrote:

Paul Baker [MVP, Windows - Networking]

unread,
Nov 22, 2006, 1:18:40 PM11/22/06
to
Good point, if you're logging into a domain the network must be up!

Paul

"ran...@newsgroups.nospam"
<randyhnewsg...@discussions.microsoft.com> wrote in message

news:2C9633F9-A162-4E3D...@microsoft.com...

Richard Mueller

unread,
Nov 22, 2006, 1:31:02 PM11/22/06
to
Either the mapping gets disconnected, which doesn't seem likely, or the
logon script is running with different credentials so the mapping is not for
the user. For example, if a Startup script maps a drive, the user won't see
it because Startup scripts run as System. Sounds crazy, but that's the only
way I can think the mapping would not error and the user not have the
mapping. Almost like setting an environment variable that only lasts as long
as the command session.

Seems this must be documented somewhere.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net

"ran...@newsgroups.nospam"
<randyhnewsg...@discussions.microsoft.com> wrote in message

news:578ACB08-14A7-49EF...@microsoft.com...

Richard Mueller

unread,
Nov 22, 2006, 1:42:18 PM11/22/06
to
Seems many people report this problem. I found this posted on a Microsoft
Vista help group:
=========
Explanation for what you are seeing and workaround :

By default Group policy service executes scripts in an elevated mode. There
are some scripts like 'Map network drives' that would need to be run in UAP
mode. In order to launch such scripts in a UAP context from an elevated
process, you can leverage the Task scheduler API. Here is a sample script:
Launchapp.wsf

Usage: cscript launchapp.wsf <AppPath>


If the user wants to run a GP logon script Script-UAP.wsf and requires it
to run in UAP context because it is mapping drives for the user then, create
another script Launch-Script-UAP.wsf which will just use the sample script
above to launch Script-UAP.wsf in UAP mode. Deploy this script as GP logon
script.

I'm attaching the LaunchApp sample script too.

This change will also be communicated via KB, Vista GP document or
otherwise.

Let me know if you still have issues.

Thanks,
Prashanth
Vista Remote File Systems.
===========
This sounds like a big problem to me. I've never used wsf files myself. More
research needed, but this is crazy.

t...@advantexmail.net

unread,
Nov 22, 2006, 1:50:03 PM11/22/06
to
There must be a better way. The script works fine when launched
manually after logon. This solution is cumbersome to say the least and
would be a hassle to integrate with XP and 2K machines.

danshane

unread,
Nov 22, 2006, 2:10:00 PM11/22/06
to
I agree that this "solution" is unwieldy and in fact unacceptable.
Drive mapping via login script is standard practice at hundreds of
organizations, and using Group Policy to do so has always been the
recommended method.

We need a *real* fix for this, not a workaround. I reported this issue
on every build of Vista betas, and still we have no solution. We won't
be upgrading to Vista on our campus until we have a satisfactory means
of performing this simple procedure.

Dan Shane
Network Systems Administrator
Indiana University

t...@advantexmail.net

unread,
Nov 22, 2006, 2:17:27 PM11/22/06
to
I cannot possibly deploy Vista until this is fixed either. I've been
really happy with Vista so far, but I just can't believe that this is
even an issue. There should really be a group policy just for drive
mapping.

randyhnewsg...@discussions.microsoft.com

unread,
Nov 22, 2006, 4:16:02 PM11/22/06
to
I assumed something like that was going on, I just wish there was better
solution. Thanks for looking into this.

Randy

dNagel

unread,
Nov 22, 2006, 7:40:07 PM11/22/06
to
Is there a policy option available that allows you to tell Windows to wait for the Network?

http://forums.techarena.in/showthread.php?t=368669

To disable this "feature" and restore your domain logons to their normal
speed, open the MMC and add the group policy snap-in. Under Computer
Configuration-->Administrative Templates-->System-->Logon, change
"Always wait for the network at computer startup and logon" to ENABLED.

??

http://www.microsoft.com/technet/scriptcenter/guide/sas_wsh_peht.mspx?mfr=true

There is a username (optional argument to MapNetworkDrive) parameter that maybe
you could push their username into, and maybe windows will prompt for the password?

D.

ran...@newsgroups.nospam wrote:
Hi,

I am working with the RTM release of Vista trying to get my organization's 
logon/logoff scripts working. I have found one problem that I need some 
assistance with.

One of our logon scripts maps drives based on group membership. It works 
fine in Vista if it is ran once a user is fully logged in but does not work 
when ran via the logon script. I have tried the following things:

 - Map the drive using WScript.Network.MapNetworkDrive.
 - Map the drive using "net use".
 - Making the script sleep for 30 seconds before mapping the drives.

Any ideas?
  

Jason McCracken

unread,
Dec 4, 2006, 8:05:00 AM12/4/06
to
The solution I used was to do this.

1) Get launchApp.wsf from the MS documentation
http://technet2.microsoft.com/WindowsVista/en/library/5ae8da2a-878e-48db
-a3c1-4be6ac7cf7631033.mspx?mfr=true

2) Created Vista_Check.vbs that I set as my login script

3) When I cut and pasted launchApp.wsf the formatting put an extra
carriage return in part of the script that I had to remove
Call rootFolder.RegisterTaskDefinition( _
strTaskName, taskDefinition, FlagTaskCreate, _
,, LogonTypeInteractive)

I have tested this against Vista, XP SP2 and Server 2003. Works just
fine and I didn't have to change anything in my actual login.vbs

Hope this helps.

Vista_Check.vbs
==============
Dim isVista
Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
GetOS
If isVista = True Then
runLaunchApp
Else
runLoginNormal
End If

Sub runLaunchApp
wshShell.Run "cscript \\<path to launchapp>\launchapp.wsf \\<path to
login>\login.vbs"
End Sub
Sub runLoginNormal
wshShell.Run "\\<path to login>\login.vbs"
End Sub

Sub GetOS
strComputer = "."
Set objWMIService =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colOSes = objWMIService.ExecQuery("Select * from
Win32_OperatingSystem")
For Each objOS in colOSes
osCaption = objOS.Caption
If instr(osCaption, "Vista") Then
isVista = True
End If
Next
End Sub

*** Sent via Developersdex http://www.developersdex.com ***

shane....@gmail.com

unread,
Dec 6, 2006, 1:08:11 PM12/6/06
to
LaunchApp.wsf doesn't work for me at all :(

It pops up that it is creating the tast and submitting it, but my drive
doesn not get mapped.

I am mapping a drive based on the users name
Anyone got any ideas why this script doesn't work?

Shane

Anders Franzen

unread,
Dec 15, 2006, 3:47:26 AM12/15/06
to
The way to get logon scripts to work is to disable UAC (User Account
Control), not the best way but hopefully MS will fix this soon.

Roland v.'t Kruys

unread,
Feb 3, 2007, 9:41:21 AM2/3/07
to
Another option.

After three days of searching for the solution, the light was fallen
upon me.

The problem:
After adding the Vista client to the existing 2003 domain, it seems that
the logon script (.vbs) in the Group Policy doesn't work at all. Only on
XP clients.

The solution (or workaround as you will):
Check if the user(s) (except for the Domain Administrator account) is a
member of the local Administrator Group. If it is, then remove the
account(s) to the local User Group. Log off and log in, to check if it
works.

For me, it works perfectly. My script uses also the Domain
Groupmembership to map the shares to the Domain Account. I didn't change
UAC-settings or anything else for that matter. If I should install a
application, I do that with the local administrator. Or I use the option
in the Group Policy to distribute the software.

With kind regards and good luck,
Roland v.'t Kruys (MCSE)
Getronics PinkRoccade

sfawcett

unread,
Feb 9, 2007, 4:37:25 AM2/9/07
to

I have used the launchapp.wsf and it works fine for any user on XP.
Drives and printers mapped ok.

It works fine for Domain admins on Vista.
As a restricted user it does not run on logon but will run if manually
run. Makes no difference if UAC on or off.
Permission problem. I cannot give students local administrator
permissions.
Idea's Please.

William Darnall

unread,
Oct 21, 2007, 11:18:56 AM10/21/07
to
Some of our users need admin rights; most do not.

If the user is NOT an admin on the computer then the same script that
works in XP works in Vista, but the launchapp approach fails.

If they are an admin, then the launchapp approach works, but the xp
script fails.

I would like to try using a selection based on whether they are local
admins. Is there an object.property that lets you know if they have
local admin rights.

Thank you,
Wm. "Steven" Darnall
Humboldt State University

Test.vbs.txt

Michael Bednarek

unread,
Oct 22, 2007, 6:06:46 AM10/22/07
to
On Sun, 21 Oct 2007 08:18:56 -0700, William Darnall wrote in
microsoft.public.scripting.wsh:

>Some of our users need admin rights; most do not.
>
>If the user is NOT an admin on the computer then the same script that
>works in XP works in Vista, but the launchapp approach fails.
>
>If they are an admin, then the launchapp approach works, but the xp
>script fails.
>
>I would like to try using a selection based on whether they are local
>admins. Is there an object.property that lets you know if they have
>local admin rights.

This registry modification solved the dilemma for me without coding any
distinction whether the user is a local administrators or not:
<http://support.microsoft.com/kb/937624>

In short:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
EnableLinkedConnections (DWORD) = 1

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"

0 new messages