electron - batch 파일

백승일·2021년 6월 24일
0

electron

목록 보기
2/2

일렉트론 앱을 만들고 나서, 시작프로그램으로 등록시키거나 다른 윈도우 커맨드를 이용하여 작업을 해야할 경우가있다. 그럴 경우에 electron앱의 package.json에서 설정할 수 있다.

"build":{
  "nsis": {
      "createDesktopShortcut": "always",
      "createStartMenuShortcut": "true",
      "include":"build/installer.nsh"
    }
}

이렇게 include부분에 batch파일을 실행시켜주는 매크로를 작성한 nsh파일경로를입력하면된다.
이 nsh파일은 여러 이벤트에서 동작하도록 설정할 수 있는데,
!macro customInstall
!macroend

customInstall은 일렉트론앱이 설치될 때 실행되는 매크로이며

!macro customUnInstall
!macroend

customUninstall은 일렉트론앱이 제거될 때 실행되는 매크로이다.

막간을 이용하여 batch파일 명령어도 봐보자.

if not "%1" == "am_admin" (powershell start -verb runas '%0' am_admin &exit /b)

커맨드 창을 관리자 권한으로 실행시키는 커맨드

schtasks /

작업 스케줄러와 관련된 작업을 할 수 있는 커맨드
등이 있다.

profile
뉴비 개발자

0개의 댓글