windows 8 / server 2012 logon scripts

Posted on 2013-10-01
Medium Priority
Last Modified: 2013-10-21
When we switched a few computers to windows 8 and windows 2012, I've noticed the logon scripts not mounting network drives anymore. If we run the scripts manually, then everything works as expected.

I have a script that maps a network share and printers, but when the logon script runs (as the user logs in), only the printers map. The network share *does not* map.  If I log in, and run the script - via windows explorer - (\\server\netlogon\logon.vbs) then the network drive maps as normal. Did something change with the new editions of desktop/server os.

I tried to enable netlogon logging, but I didn't see anything relevant.

here is the relevant portion of my code:
Note: in the process of testing, after moving files, the DCSERVER and PRINTSERVER will be the same.

Const G_DCSERVER="\\old_dc"
Const G_PRINT_SERVER="\\new_dc"

Set oNetwork = CreateObject("WScript.Network")
strUserName = oNetwork.Username
oNetwork.MapNetworkDrive "h:", G_DCSERVER & "\home$\" & strUsername
 oNetwork.AddWindowsPrinterconnection G_PRINT_SERVER & "\printer 1"
 oNetwork.AddWindowsPrinterconnection G_PRINT_SERVER & "\printer 2"
Question by:camstutz
  • 6
  • 4
  • 2

Assisted Solution

ZamZ0 earned 1000 total points
ID: 39538464
Why not use a batch file?

net use X: \\server\share

Or you could use a GPO

User Configuration\Preferences\Windows Settings\Drive Maps
LVL 15
ID: 39538625
I always use batch for my login scrips, vbscript absolutely gets finicy between editions of windows, though I'm not aware of any changes to 2012 that would be causing your issue.

The only thing that comes to mind are issues gaining permission to run the script from \\domain.com\netlogon\…yourscript.vbs?

Have you logged on as that user and browsed to the script?
LVL 15
ID: 39538633
PS, if you really want to use the vb script, try preffacing it with cscript

 cscrpt "\\domain.com\netlogon\…yourscript.vbs"

Open in new window

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.


Author Comment

ID: 39538772
I have logged in as the user and can run the script from windows explorer. I type in \\dc\netlogon\logon.vbs and things run fine. I will try the cscript idea tomorrow. The same script that works fine on a 2008R2 server and win 7 machines.  But as soon as we added windows 8 machines to the mix, the windows 8 machines do not run the script. The windows 7 machines do run the script still. I believe it is something with windows 8 / server 2012 and how it might handle scripts. No proof, just conjecture.

Expert Comment

ID: 39538786
So why not use another method? Just curious
LVL 15
ID: 39538819
PS the command is "cscript", not "cscrpt".

Author Comment

ID: 39539859
I read this this: http://powershell.org/wp/forums/topic/windows-8-and-logon-scripts/

It is potentially the UAC getting in the way. I know the GPO can map drives, but I am not certain that the GPO can check which groups a user is in before mapping a drive. I will have to research. I am going to try the cscript idea.

Author Comment

ID: 39539877
in my case, it doesn't seem the UAC is on.

Author Comment

ID: 39539903
just realized that I can create multiple GPO's and assign it to the specific OU.
LVL 15

Accepted Solution

Ben Personick (Previously QCubed) earned 1000 total points
ID: 39543127
Group based drive mapping is possible with Batch.

  If your VB script isn't working, honestly that would be your Go-To Simple solution verses multiple GPOs assigned to multiple OUs.

  The alternative is trying to keep your OU Structure the same as your group memberships which can be an administrative nightmare; making sure to move users to new OUs based on changes to group memberships and vice verse; etc.

  Either you have time to invest in fixing the VBScript issue, or you need a solution immediately, that won;t create a mess of head-aches later-on, as even if your organization is simple enough to work by using a few OUs now with only minor administrative overhead this will not always be the case int he future.

If you need a solution to get yourself up and running right his minute, just use batch, and then if you like the Vb, fix it afterwards.

Below is a script I wrote some time ago to map drives based on group membership, it runs on Windows 2000 through Windows 2012, and will get you up and running quickly.

:: Script Name: DOIFMEMBER.bat												  ::
:: Version: 1.2																  ::
:: Copyright: Ben Personick													  ::
:: Date: 2010-08-21															  ::
		SET "GroupStart=FALSE"
		SET "GroupList=_"
		FOR /F "Tokens=1-3 Delims=*" %%U IN ('net user "%username%" /domain 2^>^&1 ') DO CALL :Start-Get-Group-Membership "%%U" "%%V" "%%W"
		SET GroupList=%GroupList:_, =%
		ECHO GroupList for %UserName%: %GroupList%


			CALL :Start-IFMEMBER "Domain Users"
			IF "%ISMEMBER%"=="NO" GOTO :End-Script
			ECHO "%UserName%" Is a Member of "%IFMEMBER%"
                        ECHO NET USE * /D /Y
			ECHO NET USE A: \\SERVER\Share\Somedir\ /P
			ECHO NET USE H: \\SERVER\Home$\%UserName%\ /P
			ECHO NET USE P: \\SERVER\Share\Public\ /P

			CALL :Start-IFMEMBER "Operations"
			IF "%ISMEMBER%"=="NO" GOTO End-Map-Operations
			ECHO %UserName% Is a Member of %IFMEMBER%
			ECHO NET USE O: \\SERVER\Share\Operations\ /P
			ECHO NET USE L: \\SERVER\Share\Love\ /P

			CALL :Start-IFMEMBER "Domain Admins"
			IF "%ISMEMBER%"=="NO" GOTO End-Map-Domain-Admins
	GOTO End-Script
			FOR %%G IN (%GroupList%) DO IF /I %%G=="%IFMEMBER%" SET "ISMEMBER=YES"
			SET "Term=%~n1"&SET "GroupA=%~n2"&SET "GroupB=%~n2"
			::ECHO "%Term%" "%GroupA%" "%GroupB%"
			IF /I "%GroupStart%"=="FALSE" FOR /F %%F IN ('ECHO "%Term%" ^| Find /I "Group"') DO SET "GroupStart=TRUE"
			IF /I "%GroupStart%" NEQ "FALSE" SET GroupList=%GroupList%, "%GroupA%", "%GroupB%"
ECHO The Script Is Exiting.

Open in new window

NOTE: The Above Script has "ECHO" in front of all the drive mapping lines so you can test it.
Also, and there are a lot of niceties that can be I put into my newer scripts, but works solidly.

PS: Once you see this script working, try gutting it and put just the following line in to the batch file, and see if your vbscript runs then.

 CScript "\\yourdomain.com\netlogon\path\yourscript.vbs"

Open in new window


Author Comment

ID: 39566836
Hello All,

it has been busy here at the office and I just now got started working on this again. Thanks to all that posted, I will have to do some catching up on reading. I found the answer to get VBscript to map drives in 8 / Server 2012. Apparently when you turn the UAC off via the GUI, it doesn't actually turn off. You have to modify a registry.

Disabling UAC in 8/2012 Reference: https://social.technet.microsoft.com/wiki/contents/articles/13953.windows-server-2012-deactivating-uac.aspx

Another good Reference

I found a good work around to get rid of the scripts and set multiple GPO's. This seems to work regardless of the UAC setting.

I am awarding points to ZamZ0 for suggesting to try something else and for QCubed taking the time to write/post the bat file with good information on administration nightmare.

Author Comment

ID: 39588227
Don't want to resurrect an old post, I just wanted to post one more link for future reference for those who come across this.


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

A simple method to resolve a "keyboard not working" problem by modifying the Windows registry. This issue can often be encountered after using the VMware vCenter Converter Standalone Agent to perform a Physical-to-Virtual (P2V) conversion process.
Seizing the Operation Master Roles in Windows Server 2016 in case of FSMO holder failure.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question