Solved

elevated privileges not working in VB logon script

Posted on 2015-01-02
6
200 Views
Last Modified: 2015-01-04
I found myself unable to modify the registry or any other function that requires elevated privileges via a VB logon script at a client’s network however I can use the logon script to map network drives and other functions that can be executed by local users and do not require elevated privileges.

For Example when I map the attached code as logon script I get the error message "The operation failed.0" at logon
When I execute the same script manually after the logon I get the message that it worked and it dos create the key.

I got the same results after removing the Symantec Anti-Virus Client, is there any software restriction policy in Windows 7 that would explain this behavior?

(The Account I am using has local Admin Privileges)

HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set ObjRegistry = _
    GetObject("winmgmts:{impersonationLevel = impersonate}!\\" _
    & strComputer & "\root\default:StdRegProv")

strPath = "SOFTWARE\ScriptLogic\Device Agent\Global Settings\TEST"

Return = objRegistry.CreateKey(HKEY_LOCAL_MACHINE, strPath)

If Return <> 0 Then
    WScript.Echo "The operation failed." & Err.Number
    WScript.Quit
Else
    wScript.Echo "New registry key created" & VBCRLF _
        & "HKLM\SOFTWARE\MYKey\"

End If

Open in new window

0
Comment
Question by:David
  • 4
  • 2
6 Comments
 
LVL 42

Accepted Solution

by:
kevinhsieh earned 250 total points
ID: 40528745
The login script will run under the context of the user, but the login script isn't elevated. From your script it looks like you are trying.to modify part of HKLM of the registry, in which case I recommend that you run it as a startup script instead. Startup scripts run in the context of the localsystem account and will be able to modify that part of the registry.
0
 
LVL 42

Expert Comment

by:kevinhsieh
ID: 40528746
I do not recommend that you turn off UAC.
0
 
LVL 32

Assisted Solution

by:Robberbaron (robr)
Robberbaron (robr) earned 250 total points
ID: 40528894
kevin is correct.
but also for a startup script, all files that are referenced in that script need to be available to an 'unauthenticated' user.  So store them under NETLOGON share on the login server. (and be aware they are unsecured !)
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 42

Expert Comment

by:kevinhsieh
ID: 40529287
None of my startup scripts are under netlogon. They are in the normal location with the group policy files, which by default any can be read by at least every computer and user.
0
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 40529597
clarification.... what i meant is that any files other than the script itself.

one of my scripts copies and  installs a DLL into each PC: the source location of the DLL has to be accessible by all.

another logs its actions to a network file: the log file is in NetLogon.
0
 
LVL 42

Expert Comment

by:kevinhsieh
ID: 40530938
The other files placed alongside the startup script are accessible to the script. I do it all the time. I have startup scripts that copy DLL, EXE, etc. without issue. That area isn't generally WRITEABLE, however. Writing to NETLOGON might be less than ideal if you have more than one domain controller as your logs will end up on multiple servers.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…

820 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