{"id":2978,"date":"2016-04-18T12:04:35","date_gmt":"2016-04-18T06:34:35","guid":{"rendered":"http:\/\/198.58.113.91\/blog\/?p=2978"},"modified":"2022-12-22T21:43:09","modified_gmt":"2022-12-22T16:13:09","slug":"set-user-environment-variable-setx-windows-10","status":"publish","type":"post","link":"https:\/\/www.winhelponline.com\/blog\/set-user-environment-variable-setx-windows-10\/","title":{"rendered":"How to Set User Environment Variable Using Setx"},"content":{"rendered":"<p>You probably know how to add or remove environment variables using GUI in Windows. It can be done by launching sysdm.cpl \u2192 Advanced \u2192 Environment Variables. Alternatively, one can run the following command in the Run dialog to launch the Environment Variables dialog directly:<\/p>\n<pre>rundll32 sysdm.cpl,EditEnvironmentVariables<\/pre>\n<p><em>(To set per-system environment variables, the above command needs to be run from <a href=\"https:\/\/www.winhelponline.com\/blog\/open-elevated-command-prompt-windows\/\">admin Command Prompt<\/a>.)<\/em><\/p>\n<p>This post tells you how to use the <a href=\"https:\/\/technet.microsoft.com\/en-in\/library\/cc755104.aspx?f=255&amp;MSPPError=-2147217396\" target=\"_blank\" rel=\"noopener noreferrer\">Setx command<\/a> to add a user environment variable.<\/p>\n<h2>Setting User Environment Variable<\/h2>\n<p>Open a Command Prompt window and type <b>SETX \/?<\/b> to know the command usage. For example, to set the <code>JAVA_HOME<\/code> <a href=\"https:\/\/docs.oracle.com\/cd\/E19182-01\/820-7851\/inst_cli_jdk_javahome_t\/\" target=\"_blank\" rel=\"noopener noreferrer\">variable<\/a>, you would use:<\/p>\n<pre>SETX JAVA_HOME \"C:\\Program Files\\Java\\jdk1.6.0_02\"<\/pre>\n<p><em>(Depending upon the version of the JDK installed and the <a href=\"https:\/\/www.winhelponline.com\/blog\/find-windows-10-build-version-edition-bit\/\">bitness<\/a> of your OS, change the JDK folder path accordingly.)<\/em><\/p>\n<p>This permanently sets the environment variable for your user account; It takes effect for future Command Prompt windows.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2980\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/04\/cmd.png\" alt=\"Command Prompt\" width=\"278\" height=\"200\" \/><\/p>\n<h2>Delete a User Environment Variable<\/h2>\n<p>To clear the user variable, use this syntax\/example:<\/p>\n<pre>SETX JAVA_HOME \"\"<\/pre>\n<p>This, however, doesn&#8217;t delete the value from the following registry key:<\/p>\n<pre>HKEY_CURRENT_USER\\Environment<\/pre>\n<p>So you need another command to clear it, although this is optional.<\/p>\n<pre>REG DELETE HKCU\\Environment \/V JAVA_HOME \/F<\/pre>\n<p>This clears the JAVA_HOME user variable.<\/p>\n<p><em>Note: The Setx command can also be used to set <strong>System<\/strong> Environment Variables using the &#8220;\/M&#8221; switch, but you need to run it from elevated or administrator Command Prompt.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You probably know how to add or remove environment variables using GUI in Windows. It can be done by launching sysdm.cpl \u2192 Advanced \u2192 Environment Variables. Alternatively, one can run the following command in the Run dialog to launch the Environment Variables dialog directly: rundll32 sysdm.cpl,EditEnvironmentVariables (To set per-system environment variables, the above command needs &#8230; <a title=\"How to Set User Environment Variable Using Setx\" class=\"read-more\" href=\"https:\/\/www.winhelponline.com\/blog\/set-user-environment-variable-setx-windows-10\/\" aria-label=\"Read more about How to Set User Environment Variable Using Setx\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[8,869],"tags":[],"class_list":["post-2978","post","type-post","status-publish","format-standard","hentry","category-windows-10","category-windows-11"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":26688,"url":"https:\/\/www.winhelponline.com\/blog\/restore-path-environment-variable-deleted\/","url_meta":{"origin":2978,"position":0},"title":"How to Recover PATH Variable After Deleting it Accidentally","author":"Ramesh","date":"May 18, 2022","format":false,"excerpt":"The PATH is a variable that Windows uses to locate needed executables, especially from the command line. Unfortunately, there are situations where users accidentally delete the PATH variable. This can happen when users inadvertently overwrite the PATH data rather than appending them. There are also cases where some buggy applications\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"recover path environment variable - shadow copy hive","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2022\/05\/recover-path-variable-shadowcopy.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2022\/05\/recover-path-variable-shadowcopy.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2022\/05\/recover-path-variable-shadowcopy.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":30783,"url":"https:\/\/www.winhelponline.com\/blog\/dism-exe-not-recognized-cmdlet-ps\/","url_meta":{"origin":2978,"position":1},"title":"[Error] Dism.exe is not recognized as the name of a cmdlet","author":"Ramesh","date":"December 11, 2022","format":false,"excerpt":"When you run a DISM.exe command-line in PowerShell, the command may not be recognized. The following error is shown when you do so: dism.exe : The term 'dism.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"dism.exe not recognized - add system32 to PATH","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2022\/12\/dism-system32-path-missing-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2022\/12\/dism-system32-path-missing-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2022\/12\/dism-system32-path-missing-1.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":59342,"url":"https:\/\/www.winhelponline.com\/blog\/commands-not-recognized-internal-external-command\/","url_meta":{"origin":2978,"position":2},"title":"Commands not recognized as an internal or external command in Command Prompt","author":"Ramesh","date":"July 12, 2023","format":false,"excerpt":"When you run a command-line in a Command Prompt window, the following error may appear: 'help' is not recognized as an internal or external command, operable program or batch file. This happens even if the respective executable file is located in the Windows or System32 folder, such as help (help.exe),\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"move windows and system32 to the top of the path variable","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2023\/07\/path-variable-change-order.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2023\/07\/path-variable-change-order.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2023\/07\/path-variable-change-order.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2023\/07\/path-variable-change-order.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":79110,"url":"https:\/\/www.winhelponline.com\/blog\/default-system-and-user-environment-variables\/","url_meta":{"origin":2978,"position":3},"title":"List of SYSTEM and USER Environment Variables","author":"Ramesh","date":"July 25, 2025","format":false,"excerpt":"Windows has a default set of environment variables and their values. There are two types of environment variables: user environment variables (set for each user) and system environment variables (set for everyone). For example, the variable %USERNAME% represents the name of the currently logged-on user account. If you have inadvertently\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8452,"url":"https:\/\/www.winhelponline.com\/blog\/bat-files-do-not-run-when-double-clicked-fix-association\/","url_meta":{"origin":2978,"position":4},"title":"[Fix] Windows Batch Files (.bat) do not run when double-clicked","author":"Ramesh","date":"April 2, 2019","format":false,"excerpt":"When you double-click a Windows batch file (.bat) or a .cmd file, one of the following symptoms may happen: The error \"Windows cannot find 'filename.bat'. Make sure you typed the name correctly, and then try again.\" occurs when you run a .bat or a .cmd file. The batch file opens\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"comspec setx","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/04\/comspec-fix-setx.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/04\/comspec-fix-setx.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/04\/comspec-fix-setx.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":4094,"url":"https:\/\/www.winhelponline.com\/blog\/windir-not-resolved-recognized-fix-env-variable\/","url_meta":{"origin":2978,"position":5},"title":"Windir Path Not Resolved or Recognized. How to Fix the Environment Variable?","author":"Ramesh","date":"September 20, 2016","format":false,"excerpt":"SystemRoot and Windir are two built-in environment variables that point to your Windows directory. Although both are built-in variables, SystemRoot variable is read-only, but Windir variable can can be removed or edited, and its setting is stored in the registry.If %Windir% is not recognized or resolved by the system, your\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"windir not resolved or recognized","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/09\/windir-2.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/2978","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/comments?post=2978"}],"version-history":[{"count":0,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/2978\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/media?parent=2978"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/categories?post=2978"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/tags?post=2978"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}