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 7418233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:50:57+00:00 2026-05-29T07:50:57+00:00

When I open a windows command prompt and type set then enter, I get

  • 0

When I open a windows command prompt and type “set” then enter, I get a list of system variables.

How do I set/get those in C# using visual studio?

I tried:

System.Environment.SetEnvironmentVariable("TestVariableName", "test123");

However, when I type “set” into the command line, I don’t see my new variable called “TestVariableName” with value of “test123”.

What am I doing wrong?

Thanks

  • 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-05-29T07:50:57+00:00Added an answer on May 29, 2026 at 7:50 am

    First off, the overload of SetEnvironmentVariable that you used “Creates, modifies, or deletes an environment variable stored in the current process.” ( http://msdn.microsoft.com/en-us/library/system.environment.setenvironmentvariable.aspx?ppud=4 ).

    You should use this overload with an EvironmentVariableTarget value of Machine if you want it to affect other programs.

    Secondly, environment variables are copied from the system or the parent process when a process starts, and never change from the perspective of a running application even if they are changed in the wider system.

    In your case, start a new instance of the command line after setting the variable and you should see your variable.

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

Sidebar

Related Questions

is there any php function to open Matlab using Windows Command Prompt
In Windows, if I open a command prompt, start python, and inspect something using
I'm just trying to open a command prompt window using java program (in eclipse).
When I open a command window in windows and use the imagemagick convert command:
The code I'm playing with is: open System open System.Windows.Forms open System.Drawing let tehform
Ok I am making a simulated OS type interface. It should open up windows
I want to able to open a command prompt at the folder which contains
if a start python in a command prompt terminal and try to open some
If, at a command prompt, I run vimdiff file1 file2 I get a vim
I have a requirement where i need to open command prompt and run a

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.