IT박스

Windows의 모든 명령 줄에서 .exe를 실행할 수 있도록 "등록"

itboxs 2020. 6. 24. 07:51
반응형

Windows의 모든 명령 줄에서 .exe를 실행할 수 있도록 "등록"


Windows 명령 창의 어느 위치에서나 .exe 파일에 액세스 할 수있게하려면 어떻게해야합니까? 입력해야 할 레지스트리 항목이 있습니까?


exe가 PATH환경 변수 에있는 폴더에 있는지 확인해야 합니다.

이미있는 폴더에 설치 PATH하거나 폴더를에 추가하면 PATH됩니다.

설치 프로그램에서이 작업을 수행 할 수 있지만 시스템을 다시 시작하여 시스템을 선택해야합니다.


다음 레지스트리 키를 추가 할 수 있습니다 .

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\myexe.exe

이 키에서 exe 파일의 경로를 포함하는 기본 문자열 값을 추가하십시오.


.exe파일의 경로를 환경 변수 경로 에 넣어야합니다 . "내 컴퓨터-> 속성-> 고급-> 환경 변수-> 경로"로 이동하여 경로에 .exe의 디렉토리를 추가하여 경로를 편집하십시오 .

개인적으로 선호하는 또 다른 솔루션 은보다 부드러운 변수 편집을 위해 RapidEE사용하는 것입니다 .


실행 파일을 경로의 디렉토리에 넣는 대신 프로그램을 실행하는 경로의 디렉토리에 배치 파일을 작성해야합니다. 이 방법으로 실행 파일을 지원 파일과 분리하지 않고 동일한 디렉토리의 다른 항목을 실수로 경로에 추가하지 않습니다.

이러한 배치 파일은 다음과 같습니다.

@echo off
start "" "C:\Program Files (x86)\Software\software.exe" %*

윈도우 10, 8.1, 8

시작 메뉴를 열고

  1. 유형 Edit environment variables
  2. 옵션을여십시오 Edit the system environment variables
  3. 클릭 Environment variables...버튼
  4. System Variables상자 찾기 path변수 에 두 개의 상자가 있습니다.
  5. 딸깍 하는 소리 Edit
  6. 창이 나타나면 클릭 New
  7. 또는 파일 디렉토리 경로를 입력 하십시오 ( 디렉토리 는 파일 이름을 경로에서 제외 함을 의미합니다).exebatch
  8. Ok열려있는 모든 창을 클릭 하고 시스템을 다시 시작하여 명령 프롬프트를 다시 시작하십시오 .

  • cmd.exe 또는 배치 파일 내에서 파일을 실행하려면 .exe가있는 디렉토리를 % path % 변수 ( System 또는 User )에 추가해야합니다.
  • 실행 대화 상자 (Win + R) 또는 ShellExecute 를 호출하는 응용 프로그램에서 실행 하려면 응용 프로그램 경로 키에 exe를 추가하는 것으로 충분합니다 (설치 / 제거 중에 오류가 덜 발생하며 혼란스럽지 않습니다) 경로 변수 위로)

Windows에서 이러한 간단한 작업에 대한 간단한 해결책이 없다는 것이 놀랍습니다 .Windows에서 별칭을 정의하는 데 사용할 수있는이 작은 cmd 스크립트를 만들었습니다 (명령은 파일 헤더 자체에 있음).

https://gist.github.com/benjamine/5992592

이것은 NPM이나 루비 젬과 같은 도구에서 전역 명령을 등록하는 데 사용하는 것과 거의 동일한 접근 방식입니다.


다음과 같이 영구적으로 (재부팅 후) Path 변수에 추가 할 수도 있습니다 .

내 컴퓨터를 마우스 오른쪽 단추로 클릭 -> 특성 클릭 -> 고급 시스템 설정 클릭-> 환경 변수 클릭

참조 : 시스템 / 사용자 변수 변경


c : \ windows 디렉토리에 넣거나 환경 설정의 "경로"에 디렉토리를 추가하십시오 (windows-break-tab advanced)

안부, // t


설치시 한 줄 배치 파일을 사용하십시오.

SETX PATH "C:\Windows"

박쥐 파일을 실행

이제 .exe를 c : \ windows에 배치하면 완료됩니다.

명령 행에 'exename'을 입력하면 실행할 수 있습니다.


Windows에서 간단한 Bash와 같은 별칭

각 경로를 수동으로 경로에 추가하지 않고 자동으로 경로에 추가되지 않은 응용 프로그램에 대해 Windows에서 전역 bash와 같은 별칭을 얻으려면 시스템에 가장 적은 양의 변경을 수행하고 가장 많이 수행하는 가장 깨끗한 솔루션이 있습니다. 이후 사용자 정의를위한 유연성 :

별칭 경로 "설치"

mkdir c:\aliases
setx PATH "c:\aliases;%PATH%"

별명 추가

새 쉘 창에서 열기

시작 C:\path to\my program.exe하고 모든 인수를 전달하여 새 창에서 열려면 c:\aliases\my program.bat다음 내용으로 파일을 만듭니다 ( 시작 명령에 대한 자세한 내용은 NT 시작 명령 참조 ).

@echo off
start "myprogram" /D "C:\path to\" /W "myprogram.exe" %*

현재 쉘 창에서 실행

시작하려면 C:\path to\my program.exe모든 인수를 전달하지만, 생성 (자세한 bash는 작동 방식처럼) 같은 창에서 실행, c:\aliases\my program.bat다음 내용을 파일 :

@echo off
pushd "C:\path to\"
"my program.exe" %*
popd

현재 쉘 창 2에서 실행

If you don't need the application to change the current working directory at all in order to operate, you can just add a symlink to the executable inside your aliases folder:

cd c:\aliases\
mklink "my program.exe" "c:\path to\my program.exe"

Let's say my exe is C:\Program Files\AzCopy\azcopy.exe

Command/CMD/Batch

SET "PATH=C:\Program Files\AzCopy;%PATH%"

PowerShell

$env:path = $env:path + ";C:\Program Files\AzCopy"

I can now simply type and use azcopy from any location from any shell inc command prompt, powershell, git bash etc


Add to the PATH, steps below (Windows 10):

  1. Type in search bar "environment..." and choose Edit the system environment variables which opens up the System Properties window
  2. Click the Environment Variables... button
  3. In the Environment Variables tab, double click the Path variable in the System variables section
  4. Add the path to the folder containing the .exe to the Path by double clicking on the empty line and paste the path.
  5. Click ok and exit. Open a new cmd prompt and hit the command from any folder and it should work.

Another way could be through adding .LNK to your $PATHEX. Then just create a shortcut to your executable (ie: yourshortcut.lnk) and put it into any of the directories listed within $PATH.

WARNING NOTE: Know that any .lnk files located in any directories listed in your $PATH are now "PATH'ed" as well. For this reason, I would favor the batch file method mentionned earlier to this method.


Should anyone be looking for this after me here's a really easy way to add your Path.

Send the path to a file like the image shows, copy and paste it from the file and add the specific path on the end with a preceding semicolon to the new path. It may be needed to be adapted prior to windows 7, but at least it is an easy starting point.

Command Prompt Image to Export PATH to text file


The best way to do this is just install the .EXE file into the windows/system32 folder. that way you can run it from any location. This is the same place where .exe's like ping can be found

참고URL : https://stackoverflow.com/questions/4822400/register-an-exe-so-you-can-run-it-from-any-command-line-in-windows

반응형