Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

elevated privileges not working in VB logon script

Posted on 2015-01-02
6
Medium Priority
?
212 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 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Question has a verified solution.

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

Here's a look at newsworthy articles and community happenings during the last month.
A bad practice commonly found during an account life cycle is to set its password to an initial, insecure password. The Password Reset Tool was developed to make the password reset process easier and more secure.
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
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.
Suggested Courses

926 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