How to add C:\windows\system32 to path on Windows 8? - windows

Just checked my path ... noticed that C:\windows\system32 was not present.
How can I add this to my path variable, since setx isn't a recognized command? I'm using Windows 8.1 Enterprise if that helps.

PATH=%PATH%;c:\windows\system32
would work at the command line. This will only change it until the command shell exists.
If you go to user accounts and your account I think there is edit environment variables on the left. This will change it for all subsequent sessions.
Consider not changing it permenantly

Related

Path environment variable while running a Windows service under a user account

I am running a Windows service (I cannot modify) under a given user account. The service does a few things, among them runs a bat script that I should provide.
I discovered that the PATH variable available to the service (as seeen by Sysinternal Process Explorer) is the user PATH environment variable. The default is %USERPROFILE%\AppData\Local\Microsoft\WindowsApps which limits the available command in the script to the built-in cmd commands. I need to have a few more path, as when using cmd where the PATH is the merge of user PATH and system PATH.
Short of changing the user PATH variable and adding part of or all system PATH, is there a way to change user PATH variable that would be seen by the Windows service?
I found a suggestion about editing the registry in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\YourService in order to add a PATH environment variable. While it could be the solution I was looking for, unfortunately it did not work. Any suggestion ?

Setting default path with custom variable in windows 10pro

I have been trying to get windows to recognize shortcuts for developer tools. Things like adb for C:\Users\myusername\Andriod\platform-tools\adb.exe. I have tried using CMD and Powershell but they both don't add the PATH I tried the GUI and it doesn't show up.
I've tried setx path "%PATH%;C:\path\to\C:\Users\myusername\Andriod\platform-tools\adb.exe" in powershell and cmd then restarted powershell or cmd
input the variable adb but it pulls a command not recognized error.
Did you try the following?
Adding the path "C:\Users\myusername\Andriod\platform-tools" to your system/user PATH variable? You can do this by start-> environment variable -> environment variable and under system or user, edit the PATH variable and add the above link. Once you do this, restart CMD for it to work.
Add the executable in one of the already existing locations that are in the PATH variable. (Although this is one method, I would not suggest this). Again, if the executable has any dependencies, it must be in a place where the exe itself can access.

Windows PATH variable is different if whether running CMD as admin or not

I just installed scala but I can't call it from the command line. So I dutifully checked my path through the environmental variables of the control panel and saw the scala folder present. If I type scala from cmd within that folder, it works fine.
So I tried echo %PATH% from windows cmd to see any problem. If running a normal command window, I get almost the same path except it's missing the scala path item. If I run the command line (Admin), then the echoed path matches the environment variables version. Under this admin setting, scala works fine.
There is no user path variable defined, it's only a system variable.
I've never seen this before. Why is there a difference between admin path and non-admin path? And how do I access the scala path item from the non-admin command line?
Thanks!
I just had the same problem, it was caused by the environment variables not being refreshed. A reboot would have solved it, however there is a way to refresh the environment variables without a reboot.
Open cmd prompt window
Input set PATH=C
close and restart cmd prompt window
input echo %PATH% to check
This worked for me in Windows 10.

Changing the PATH from a batch

I'm writing a dos-batch in which I need to change the PATH.
I'm using the SET command.
The batch is run from the command line (cmd.exe).
The problem : the changes are only available for the cmd window, and I soon as this window is closed, the changes are dismissed.
How can I change the PATH from a batch and make sure the change will affect the whole system ?
There is a tool setx.exe provided in the Windows XP Service Pack 2 Support Tools that can be used to permanently change an environment variable from the command line:
setx path "%PATH%;C:\New Folder"
Source: http://vlaurie.com/computers2/Articles/environment.htm
The above link also gives the location of the registry keys that store the system / user environment variables - if you are feeling adventurous you could also try setting those.
User environment variables:
HKEY_CURRENT_USER\Environment
System environment variables:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

Running programs easily from a command line on Windows

Linux allows me to have a short system path by placing binaries in just a few locations. I don't have to edit the path because I just installed a new application, and I don't have to hunt for applications I want to run. How can I, with PowerShell as the program I use to launch programs from, accomplish the same thing on Windows (Vista)?
Windows Vista has symlinks now via mklink.
Perhaps you could setup a "C:\bin" folder and generate symlinks to point back to the original binaries. That is assuming that Windows Vista's symlinks work similarly to the ones in Linux. Here's a short tutorial.
Many programs create an application paths entry in the registry (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths). For those applications, you can start them like so:
PS> Start-Process <application name>
PS> Start-Process excel
If you don't have PowerShell V2, which provides Start-Process, you can use the PowerShell Community Extensions on V1.
It sounds like adding a few directories to your path environmental variable might help. From the command prompt you can view all environmental variables with the set command. Then you can cut and paste your path and use set again to add to it.
If you prefer the GUI route, right click on My Computer → Properties → (in Windows Vista and Windows 7 go to "Advanced System Settings" on the left. In Windows XP, skip this step) → Advanced Tab → At the bottom there is an Environmental Variables button.
When something is invoked from the command line, Windows checks in all the directories marked in the path first. After your application directory is in the path, you can execute it without fully qualifying your path.
You could always add a .cmd file as an alias.
I install applications into C:\bin.
Using specifically PowerShell you can just create aliases for programs you want to start. I doubt that this is actually less work than editing the PATH environment variable, though.

Resources