I know that in the unix world, if you edit your .profile
or .cshrc
file, you can do a source ~/.profile
or source ~/.cshrc
to get the effect on your current session. If I changed something in the system variable on Windows, how can I have it effect the current command prompt session without exiting the command prompt session and opening another command prompt session?
The winget tool source command allows you to manage sources for Windows Package Manager. With the source command, you can add, list, update, remove, reset, or export repositories.
To access the shell, simply type 'bash' in the Windows command prompt, and everything is good to go.
CMD is the command line for Microsoft Windows operating system, with command-based features. Powershell is a task-based command-line interface, specifically designed for system admins and is based on the . Net Framework. Bash is a command-line and scripting language for most Unix/Linux-based operating systems.
If you select and hold (right-click) a file or folder in this dialog box, a standard Windows shortcut menu appears. Select OK to append the selected folder to the source path and return to the Source Search Path dialog box.
In the usual Windows command prompt (i.e. cmd.exe), just using call mybat.bat
did what I wanted. I got all the environment variables it had set.
The dos shell will support .bat files containing just assignments to variables that, when executed, will create the variables in the current environment.
c:> type EnvSetTest.bat
set TESTXYZ=XYZ
c:> .\EnvSetTest.bat
c:> set | find "TESTX"
TESTXYZ=XYZ
c:>
IHTH.
Following example will help you to solve your problem.
env.bat
This file is for setting variables. Its contents are given blow.
set name="test3"
test.bat
Our main batch file.
call env.bat
call print.bat
pause
Now print.bat
batch file to print variables. Its contents given below
echo %name%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With