Problem running computer logon script from netlogon share

I have a computer logon script (under admin templates/System/Logon) that is a simple vb script to rename my computer. Code attached.

It runs fine if I enter the path as \\server1\netlogon\script.vbs.

If I enter the path as \\domain.local\netlogon\script.vbs, users are prompted to run the script.

I'd like to resolve this because I don't like having to reconfigure (or at least check) GPOs whenever a DC is demoted.
Const MY_COMPUTER = &H11&
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER) 
Set objFolderItem = objFolder.Self
objFolderItem.Name = "My Computer " & strComputer

Open in new window

Who is Participating?
oBdAConnect With a Mentor Commented:
The users are probably prompted because "domain.local" isn't recognized as Local Intranet in the security settings of IE.
There's an easy solution: use %Logonserver% instead of "\\server1" (%LogonServer% DOES include the two leading backslashes); %LogonServer% contains the DC which just authenticated the user, so in all likelihood, it's running ...
jonhicksAuthor Commented:
Yup, you're right. If I use windows explorer and browse to \\server1\netlogon\ and launch the script, it runs without a warning. If I run it from \\domain.local\netlogon, it throws up the security warning.

If I add file://*domain.local to the local Intranet zone in IE, it works without the warning.

I tried setting the script path as %logonserver%\netlogon\script.vbs but it didn't run. Not sure if you can only call this variable from inside a script? Nothing in the event log.
jonhicksAuthor Commented:
Resolved the problem by running a computer startup script to add file://*.domain.local to the Local Intranet zone.

computer logon scripts run from \\domain.local\netlogon now run without a security warning.

Odd that this only affected computer logon scripts and not user logon scripts (which run fine without a warning).
On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\" _
    & "ZoneMap\Domains\domain.local"
objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
strValueName = "file"
dwValue = 1
objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue

Open in new window

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.

All Courses

From novice to tech pro — start learning today.