[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Run section of vbscript code with elevated privilages

Posted on 2006-04-12
Medium Priority
Last Modified: 2010-05-18
Hope this is in the right topic area, couldn't see one dedicated to vbscript.  I've been asked to add the following code to our logon script to disable microsoft firewall on all clients.

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile
objPolicy.FirewallEnabled = FALSE

This code runs fine as an administrator but users unsuprisingly get a permission denied error.  My question is this, can I run these 3 lines of code as an administrator?  I want all other code in the script to run as the logged in user.  

Many Thanks
Question by:bon3s
  • 2

Accepted Solution

Taconvino earned 2000 total points
ID: 16439037
Maybe you can make these three lines as another script and run it as a startup script instead of a logon script.  Check this for push in the right direction:


Hope this helps!


Author Comment

ID: 16444076
Thanks Taconvino, although this doesn't directly answer my question (I assume it cannot be done?), your solution is actually a far better way to do this.  Much better than having administrator username and password hard coded in the script.  I would have encrypted it, but still they're easy enough to unencrypt so it would have been a concern.

Much appreciated.

Expert Comment

ID: 16446051
You are very much welcome!  

I'm not sure if this can be done or not... using RunAs is not an option, and I can't think of any other way.


Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month19 days, 22 hours left to enroll

872 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