Link to home
Start Free TrialLog in
Avatar of jonhicks
jonhicks

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jonhicks
jonhicks

ASKER

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.
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