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

  • Home
  • SEARCH
  • 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 8642249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:43:42+00:00 2026-06-12T11:43:42+00:00

Why won’t Environment.GetEnvironmentVariable(variableName) get a variable’s value if the call is made from within

  • 0

Why won’t Environment.GetEnvironmentVariable("variableName") get a variable’s value if the call is made from within a webMethod hosted on IIS and it will work if I call it from a console application on the same machine?

Where do I set up those variables to be visible to IIS web services? Should I use the second parameter from Environment.GetEnvironmentVariable(name, target) to get it?

It is actually really simple:

[WebMethod(Description = "Gets the environment variable value.")]
public string GetEnvironmentVariable()
{
    return Environment.GetEnvironmentVariable("VARIABLE_NAME_HERE");
}

And by the way, VARIABLE_NAME_HERE is set at the system and user level.

  • 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-12T11:43:44+00:00Added an answer on June 12, 2026 at 11:43 am

    Read here for more information:

    Using System Wide Environment Variables in .NET Application


    Specifically:

    What Are System Environment Variables?

    Environment variables are strings that save information about the
    entire environment in your system. These string values are dynamic and
    they can affect the way your system will behave on. Environment
    variables can be classified into two main types:

    System Variables: They affect the entire system whatever the current
    user is. They are defined by Windows and saved in the registry. You
    need to be an administrator to be able to modify them. You usually
    need to restart your computer to make these changes effective.

    User Variables: They affect the current environment of the current
    system user. They can be deleted, modified, and added by any system
    user. They are used by Windows setup, by some programs, and by users.
    Changes to these variables are saved to the registry and be effective
    immediately.


    If you try to access an environment variable that does not exist on your machine you will have issues. You must be trying to find a variable that exists on your local machine, but not on your web service’s host machine.

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

Sidebar

Related Questions

From reasons I won't get into, all our unit tests are using the VSTS
Why won't the UILabel: lbl update on the iPhone? ... from within a method:
Mono won't fire the following code: I get internal server error 500, error writing
Why won't my simple c++ code compile? get undeclared identifier errors. I can't see
Why won't my Telerik ComboBoxFor bind my value and fill my ComboBox via AJAX?
For reasons I won't go into, I wish to ban an entire company from
Why won't foo get appended? $.ajax({ type: 'GET', dataType: 'json', cache: false, url: 'barfoochakalaka',
My android app won't seem to start. I made a few code changes in
Why won't it shuffle the array so I get a random result each time?
I won't tell you I've searched and tried dozens of syntaxes from the internets.

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.