Is it possible to assign value to set (not setx) value %path% on Windows 10?

You have "" in your path. They should not be added.

Try

set path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;

Also, why not change path like so?

set path=C:\mydir;%path% 

that ensures that your path keeps all original path settings and only adds whatever you want to add...


You may be considering also use setlocal and endlocal

Starts localization of environment variables in a batch file. Localization continues until a matching endlocal command is encountered or the end of the batch file is reached.*

Remarks

If you use setlocal outside of a script or batch file, it has no effect. Use setlocal to change environment variables when you run a batch file. Environment changes made after you run setlocal are local to the batch file. The Cmd.exe program restores previous settings when it encounters an endlocal command or reaches the end of the batch file.

You can have more than one setlocal or endlocal command in a batch program (that is, nested commands).


  • You can also use system variables to define your "alternative" path:
 rem :: %~DP0%                     == > Drive + Path from where your bat file is
 rem :: %__CD__%
 rem :: %Windir%
 rem :: %__AppDir__%
 rem :: %ProgramFiles%
 rem :: %ProgramFiles(x86)%
 rem :: %AppData:Roaming=Local%    == > Replace Roaming to Local in: %Userprofile%\AppData\Roaming to %Userprofile%\AppData\Local

for %%i in ("%~DP0%","%__CD__%","%Windir%","%__AppDir__%","%ProgramFiles%","%ProgramFiles(x86)%","%AppData:Roaming=Local%")do echo\%%~i
  • Output/Results:
F:\Q1615715\
F:\Q1615715\
C:\WINDOWS
C:\Windows\System32\
C:\Program Files
C:\Program Files (x86)
C:\Users\ecker\AppData\Local

  • Obs.: Use "" in your set "path=....strings;strings;..." only:
                                                                  
 set "path=%__AppDir__%;%Windir%;%__AppDir__%Wbem;....\WindowsApps;"

@echo off

setlocal

set "workdir=%__CD__%"

timeout 30

set "path=%__AppDir__%;%Windir%;%__AppDir__%Wbem;%__AppDir__%WindowsPowerShell\v1.0\;%ProgramFiles(x86)%\NVIDIA Corporation\PhysX\Common;%ProgramFiles%\NVIDIA Corporation\NVIDIA NvDLISR;%AppData:Roaming=Local%\Microsoft\WindowsApps;"

echo.your alternative and current %%path%%

echo\%path:;=&echo\%

timeout 30

endlocal

echo.your system and current %%path%%

echo\%path:;=&echo\%
  • Outputs:
Waiting for  0 seconds, press a key to continue ...

your alternative and current %path%

C:\Windows\System32\
C:\WINDOWS
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR
C:\Users\ecker\AppData\Local\Microsoft\WindowsApps


Waiting for  0 seconds, press a key to continue ...

your system and current %path%

C:\Program Files\Python39\Scripts\
C:\Program Files\Python39\
C:\Python38\Scripts\
C:\Python38\
C:\Program Files\ImageMagick-7.0.10-Q16-HDRI
C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64_win\mpirt
C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32_win\mpirt
C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64_win\compiler
C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32_win\compiler
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\WINDOWS\System32\OpenSSH\
C:\Program Files (x86)\QuickTime\QTSystem\
C:\Program Files\dotnet\
C:\Program Files\Microsoft SQL Server\130\Tools\Binn\
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\
C:\Program Files\nodejs\
C:\ProgramData\chocolatey\bin
C:\Program Files\Microsoft VS Code\bin
C:\Program Files (x86)\Gpg4win\..\GnuPG\bin
C:\Program Files (x86)\Sennheiser\SenncomSDK\
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR
C:\Program Files (x86)\HP\IdrsOCR_15.2.10.1114\
C:\Program Files\Git\cmd
C:\Program Files (x86)\PDFtk\bin\
C:\Ruby30-x64\bin
C:\Users\ecker\AppData\Local\Microsoft\WindowsApps
C:\Users\ecker\AppData\Roaming\npm
C:\Users\ecker\.dotnet\tools