Reputation: 1183
I followed this video: https://www.youtube.com/watch?v=Y2q_b4ugPWk and got my cmd to recognize python as a path variable. But this only works if I open cmd and powershell as an Admin. How do I get it to work for all users?
As Admin:
PS C:\windows\system32> python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
As user:
PS C:\Users> python
python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ python
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (python:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users>
Upvotes: 0
Views: 726
Reputation: 170
I build a batch opener for my powershell script. Once open in elevated privileges any other script called is also elevated. I do a similar thing with .vbs to open batch in admin.
@ECHO off
ECHO Please Wait.
powershell.exe -ExecutionPolicy ByPass -file "File.ps1"
ECHO.
ECHO PRESS ANY KEY ONCE DEBUGGED
Pause >nul
exit
Upvotes: -1
Reputation: 19664
With elevated privileges (right-click powershell.exe
, run as admin)
$PathToPython = 'C:\whatever\containingfolderforpythonexe'
$CurrentValue = [Environment]::GetEnvironmentVariable('Path', 'Machine')
[Environment]::SetEnvironmentVariable('Path', "$CurrentValue;$PathToPython", 'Machine')
Upvotes: 2