SamSuka
GuidedHacking
GuidedHacking

patreon


Windows Environment Variable API Introduction

This article will teach you about what Window environment variables are, how are environment variables on Windows stored, what are the Windows API functions that help you manipulate the environment variables, How to use these Windows API functions and more.

The Windows API is extremely useful and powerful. It helps us manipulate multiple things on Windows without dealing with the hassle of manually figuring out everything and one such thing that we can do with the Windows API is manipulating the environment variables.

How can I set a new Windows environment variable?
You can use the Windows API function SetEnvironmentVariable, or you can use the manual method using the System Properties window in the Control Panel. Remember that changes made via the API only affect the current and child processes, not the whole system.

How can I view all environment variables in my Windows system?
You can see all environment variables by opening System Properties → Advanced → Environment Variables. Alternatively, you can use the GetEnvironmentStrings API function and parse the resulting string, or use the set command in the Command Prompt.

What are some commonly used environment variables in Windows?
Commonly used environment variables include PATH (lists directories for searching executable files), TEMP (points to the directory where temporary files should be stored), USERPROFILE (gives the location of the current user's profile directory), and SYSTEMROOT (gives the root directory of the Windows operating system).

Related Windows Internals Resources​


More Creators