none
Script Issue for Windows 2012 R2 or 2012 Operating Systems RRS feed

  • Question

  • I have this login script that works on older operating systems but fails to run under Window 2012 R2 for users when the login; its setup as a active directory domain user logon policy: Im not much with scripts ..any help you could provide would be great

    -----------------------------------------------------------------------------------------------------------

    Option Explicit

    Dim objFSO, objFolder, strDirectory, WshS, WSHSell, strDriveLetter, intRunError, objShell, strUser
    Dim objNetwork, usrProfile, strProfilepath, usrName

    Set WshS = WScript.CreateObject("WScript.Shell")


    'Expand Environment
    'Create const's to spare time and place
    usrProfile = WshS.ExpandEnvironmentStrings("%UserProfile%")
    usrName = WshS.ExpandEnvironmentStrings("%UserName%")

    ' Message to prove my string contains the path to my profile
    strProfilepath = usrProfile

    ' CREATE FOLDERS ON USER SHARE IF IT DOES NOT EXIST AND ASSIGN RIGHTS
    strDirectory = "\\hadfs1.pmhadley.com\users\" & usrName

    ' Create folder in share.
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    If Not objFSO.FolderExists(strDirectory) Then
    Set objFolder = objFSO.CreateFolder(strDirectory)

    ' Grant permissions to user in the folder.
    Set objShell = CreateObject("Wscript.Shell")

    intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " & strDirectory & " /t /c /g " & usrName & ":C ""Domain Admins"":F", 2, True)

    strDriveLetter = "U:"
    Set objNetwork = CreateObject("WScript.Network") 
    objNetwork.MapNetworkDrive strDriveLetter, strDirectory 

    ELSE IF objFSO.FolderExists(strDirectory) Then

    strDriveLetter = "U:"
    Set objNetwork = CreateObject("WScript.Network") 
    objNetwork.MapNetworkDrive strDriveLetter, strDirectory

    END IF
    END IF

    --------------------------------------------------------------------

    It works if I run the script on the server from command prompt; but Remote Desktop sessions dont show the mapping created


    • Edited by QuickN Monday, April 27, 2015 7:34 PM
    Monday, April 27, 2015 7:22 PM

Answers

  • Use Group Policy.  Redirect users folders to a share.  Set users home folder and drive to point to the share.  This can also be done in Group Policy.  We have not had to do this with script since Windows 2000. It was necessary in Windows NT 4 and earlier.

    There are many good articles in the MSDN and TechNet libraries on provisioning users in modern Windows.


    \_(ツ)_/

    Monday, April 27, 2015 9:06 PM

All replies