Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7812761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:37:08+00:00 2026-06-02T04:37:08+00:00

I have to create a script which updates a system environment variable (based on

  • 0

I have to create a script which updates a system environment variable (based on a command line parameter) before launching a program.

In Windows 7, updating the system environment variable is denied. I would like to perform a privilege elevation for just the setting of the env. var. But run the program as a normal user.

How to do it?

Note:
I’ve tried the following solution:

Using 2 scripts:

  • 1 master which get all information from command line, which call the slave script to change the system env. var., and which finally launch the program
  • 1 slave script that update the system env. var.
  • the master script tries to call the slave script using privilege elevation, but that does not work

I’ve try 2 solutions for the privilage elevation:

  1. Using the “runas /User:Administrator …” command but it ask for the Administrator password: Fail
  2. Using the “ShellExecute …., “runas”” command but it tells me that my script is not an application: Fail
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:37:09+00:00Added an answer on June 2, 2026 at 4:37 am

    I found a way that is working at least on Windows 7 (don’t know if it will work on the few Windows XP hat we still have around).

    I did the following from the main script:

    currentDirectory = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))
    
    Set UAC = WScript.CreateObject("Shell.Application")
    UAC.ShellExecute "wscript.exe", currentDirectory + "my-script.vbs /Param1:Value1 ...", "", "runas", 0
    

    And the my-script is doing the sys var env update.

    Note: My fist experience with ShellExecute failed because I was trying to execute the script. Instead of “wscript.exe” I had “my-script.vbs” for the executable name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script which creates a user-defined object like this: obj = new
I have a PHP script which creates and listens on a port for connections
I have a page which is largely created by DOM script, which generates a
I have to create a script that takes a mySQL table, and exports it
Say I have written a Create Table script in a query window and run
I have to create a PNG / JPEG image from PHP script .. Briefly
I have a column with a DEFAULT constraint. I'd like to create a script
I have a script that create a new div element. Then, I want to
I have the following script to create a table: -- Create State table. DROP
I have a php script to create jpg thumbnail of pdf as follows; <?php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.