아래와 같이 유저 환경 변수를 추가하고.. 시스템에 반영할 수 있음.
C:\> reg add "HKEY_CURRENT_USER\Environment" /v "TEST" /d "C:\Test" /f
C:\> powershell -command "[Environment]::SetEnvironmentVariable('TEST', 'C:\Test', 'User')"
단 시스템 환경변수에 TEST가 이미 있다면 시스템 환경변수가 우선함.
그리고.. 환경 변수 추가 전에 특정 프로그램이 실행중이었고 TEST 환경변수를 참조하고 있다면..
프로그램을 재시작해야 함. 이럴 땐 아래와 같이 환경변수 추가 후 메시지 박스를 띄워 주는 것도 도움이 됨.
C:\> powershell -Command "Add-Type -AssemblyName PresentationFramework; [System.Windows.MessageBox]::Show('Please restart the Application.', 'Alert')"
이걸 배치파일로 한다면..
REM env.bat
reg add "HKEY_CURRENT_USER\Environment" /v "TEST" /d "C:\Test" /f
powershell -command "[Environment]::SetEnvironmentVariable('TEST', 'C:\Test', 'User')"
powershell -Command "Add-Type -AssemblyName PresentationFramework; [System.Windows.MessageBox]::Show('Please restart the HyperWorks.', 'Alert')"
'블로그 (Blog) > 개발로그 (Devlogs)' 카테고리의 다른 글
Mesh Solid Clipping 구현 (0) | 2025.05.07 |
---|---|
PySide6 용으로 Python 콘솔 작성하기 (0) | 2025.04.30 |
LÖVE (0) | 2025.04.19 |
Natural sort for items of QTreeView of PySide. (0) | 2025.04.15 |
Python List <--> Tcl List 상호 변환 (0) | 2025.04.03 |