Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

elevated privileges not working in VB logon script

Posted on 2015-01-02
6
Medium Priority
?
205 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 42

Accepted Solution

by:
kevinhsieh earned 1000 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 1000 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Let's recap what we learned from yesterday's Skyport Systems webinar.
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Suggested Courses

721 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