[英]How to make a windows 10 install file
I want to know if Windows offers an installation script or tool to install node runtime and my node js code.我想知道 Windows 是否提供安装脚本或工具来安装节点运行时和我的节点 js 代码。
This is what I want to:这就是我想要的:
pm2
to run the code like node app.js
pm2
运行node app.js
类的代码The can download this installation file.可以下载这个安装文件。 Click on it once, all this will run.
单击一次,所有这些都会运行。 Like a bat file or power shell script.
像 bat 文件或 power shell 脚本。
I did not test this extensively, but it should at least give you some ideas for getting started.我没有对此进行广泛的测试,但它至少应该为您提供一些入门的想法。
Invoke-WebRequest
to download the Node.js Windows installerInvoke-WebRequest
下载 Node.js Windows 安装程序Start-Process
and msiexec.exe
to install itStart-Process
和msiexec.exe
安装它npm
to install the latest version of PM2npm
安装最新版本的 PM2Invoke-WebRequest
again to download the Node app fileInvoke-WebRequest
下载 Node 应用程序文件New-JobTrigger
and Register-ScheduledJob
New-JobTrigger
和Register-ScheduledJob
创建一个在登录时运行的计划任务,而不是自定义 Windows 服务Invoke-WebRequest -Uri "https://nodejs.org/dist/v14.17.1/node-v14.17.1-x64.msi" -OutFile ".\node-v14.17.1-x64.msi"
Start-Process msiexec.exe -Wait -ArgumentList "/i node-v14.17.1-x64.msi /quiet"
npm install pm2@latest -g
Invoke-WebRequest -Uri "node-app-url" -OutFile ".\app.js"
$trigger = New-JobTrigger -AtLogOn -RandomDelay "00:00:30"
Register-ScheduledJob -Trigger $trigger -ScriptBlock { pm2 start app.js } -Name "RunNodeAppAtLogon"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.