Run section of vbscript code with elevated privilages

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
Who is Participating?
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!

bon3sAuthor Commented:
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.
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.