前言
Net core 项目部门在Windows有很多种方式,大致有以下几种,
其中优劣对比在这不进行累述。我今天是把它搭建到windows服务上的,这种方式对于我们现有dotnet来说相对美观(一个黑框框,一个看不到),电脑重启可以自动重启。
1.实现
1.1.下载nssm
官网http://cnfg.exe.
This operation took away office automation problems in my system.
A Desktop folder seems to be necessary in the systemprofile folder to open file by Excel.
It disappears from Windows2008, Windows2003 had the folder,
and I think it cause this error.
即在C:\Windows\System32\config\systemprofile和C:\Windows\SysWOW64\config\systemprofile目录下创建名为Desktop目录即可解决问题
该方法确实解决了我的问题
4.3.数据库备份重启服务问题,改为重启windows服务,所以请用上面的install.bat运行不要,改变Service name。
重启服务代码:
try { ServiceController service = new ServiceController("NPSWebCoreService"); if (service.Status == ServiceControllerStatus.Running) { service.Stop(); service.WaitForStatus(ServiceControllerStatus.Stopped); } service.Start(); service.WaitForStatus(ServiceControllerStatus.Running); } catch (Exception){}4.4.netcoreweb要基于mysql 服务问题,担心再启服务器的时候,mysql和windows 服务启动顺序的问题,我在启动bat 中怎么了判断mysql服务是否启动的判断。
bat 内容:
@echo offSETLOCAL enabledelayedexpansionrem 关闭自动输出:beginfor /f "skip=3 tokens=4" %%i in ('sc query MySQL') do set "zt=%%i" &goto :next:nextif /i "%zt%"=="RUNNING" ( echo 已经发现该服务在运行。) else ( net start MySQL80 echo 已经发现该服务在运行1。)rem 接收输入rem 输出得到的输入信息echo 启动NPSWebCoredotnet ./NPSWebCore.dll@echo 启动结束exit总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。