We help IT Professionals succeed at work.

Problem with AD Logon Script referring to VBS file

bobgraf asked
We run Windows Server 2008 R2. I created a logon script that referred to a VBS file that would map network locations instead of mapped drives since we want to get away from mapped drives. I created two new users that I was testing the script on. Both these users wont map the network locations to their profiles. I then put the script for my logon and it works just fine. What could be wrong with the users profiles or a setting on their computer that would cause the script to not work. I can place the scripts on their desktop and can run it that way but we want it to run when they logon. Note - The script runs fine just wont auto load on logon for the new users that were copied from another.  

Here is the Logon

@echo off

NET USE * /d /y

start C:\design.vbs    (runs off server in reality)

VBS Script

Set WSHShell = CreateObject("WScript.Shell")

Const NETHOOD = &H13&

Set objWSHShell = CreateObject("Wscript.Shell")

Set objShell = CreateObject("Shell.Application")

Set objFolder = objShell.Namespace(NETHOOD)
Set objFolderItem = objFolder.Self
strNetHood = objFolderItem.Path

strPath = objFolderItem.Path & "\*.*"
On Error Resume Next
objFSO.DeleteFile strPath, true

strShortcutName = "Shortcut"
strShortcutPath = "\\server\folder"

Set objShortcut = objWSHShell.CreateShortcut _
(strNetHood & "\" & strShortcutName & ".lnk")
objShortcut.TargetPath = strShortcutPath

Watch Question

Will SzymkowskiSenior Solution Architect
Most Valuable Expert 2015
Top Expert 2015

When you are referencing a script in the Logon Script area under the profile Tab in the AD Account, these scripts need to be located in the Netlogon Share. This Share gets replicated among all of the DC's in the domain.

If you have the script anywhere else other than in the Netlogon Share it will not work.
if you want to run logon scripts from a network location and not the Netlogon Share then you would use GPO's and startup scripts referencing the complete path where the script is located.

Personally, not sure why you wouldn't use Group Policy Preferences for mapping network drives. It is much easier and much more flexible.

Take a look below for more details on this.



I've requested that this question be deleted for the following reason:

I figured it out myself
Will SzymkowskiSenior Solution Architect
Most Valuable Expert 2015
Top Expert 2015


This ticket has been open all after noon with no comments, and as soon as i post something you state that you resolved this issue on your own with no explanation on how you corrected this issue.


Problem was a $ when I was directing it to the server drive example server\C$\folder\design.vbs   removing the $ fixed it. I wasn't running the vbs script off the AD server. The logon script was running from the Netlogon shares but I referred the start file (vbs) to a shared network drive that would allow users permission to run it. As I stated before when I pathed the location I included a C$ which was an admin function which caused the user not to be able to run the file and get an access denied. We don't use GP as unfortunately each user generally has a different set of mapped drives currently. We don't want to use mapped drives due to the randsomware virus and go with network locations that has seemed to prevent the virus from hopping on the server. IF there is GP that will do network locations rather than mapped drives I am open checking it out. I did not refresh the page when I deleted the question so I did not see that you posted and for that I apologize however the answer you gave wouldn't have helped anyway.
Will SzymkowskiSenior Solution Architect
Most Valuable Expert 2015
Top Expert 2015

Forgot to refesh the page? The question has been open for 4+ hours. Anyways glad you got your answer.