[英]Starting batch file from Task scheduler point to C:\Windows\system32
I want to start a service which requires to work open cmd console.我想启动一个需要打开 cmd 控制台的服务。
When I manually after login start a batch script from author of service (It cannot be closed - otherwise the service stop working)当我在登录后手动启动服务作者的批处理脚本时(无法关闭 - 否则服务停止工作)
@echo off
color 0
echo Preparation aplication Currenda Statistic Portal Version: 0.1 Beta (Raport) to start ...
echo Enter port, on which aplication will be available in web browser
set /p port="Enter port: "
echo Aplication will be started at: http://localhost:%port%
"libraries\bin\java.exe" -Xms2G -Xmx3G -jar raportgmin.jar --server.port=%port%
Evething works fine and the entered configuration (connections to database) saves in: Evething 工作正常,输入的配置(与数据库的连接)保存在:
D:\Statistic Portal\data\databases
D:\统计门户\数据\数据库
But I want to start this service automatically so I changed the script like below但我想自动启动此服务,所以我更改了如下脚本
@echo off
color 0
echo Preparation aplication Currenda Statistic Portal Version: 0.1 Beta (Raport) to start ...
echo Aplication will be started at: http://localhost:9090
"D:\Statistic Portal\libraries\bin\java.exe" -Xms2G -Xmx3G -jar "D:\Statistic Portal\raportgmin.jar" --server.port=9090
and starts it from Schedule Task - the service works fine but the configuration file saves in:并从计划任务启动它 - 服务工作正常,但配置文件保存在:
C:\Windows\system32\data\databases
C:\Windows\system32\data\databases
My question我的问题
What I need to change in order to service start from schedule task and saves configuration files in为了从计划任务开始服务并将配置文件保存在
D:\Statistic Portal\data\databases
D:\统计门户\数据\数据库
not in不在
C:\Windows\system32\data\databases
C:\Windows\system32\data\databases
Thank you very much..非常感谢..
I edit batch file following your advice and everything seems to be work as I need and want.我按照您的建议编辑批处理文件,一切似乎都按我的需要和需要工作。
One more time thank you.再来一次谢谢。
@echo off
CD /D "D:\Statistic Portal"
color 0
"D:\Statistic Portal\libraries\bin\java.exe" -Xms2G -Xmx3G -jar raportgmin.jar --server.port=9090
@Start "Statistic Portal Version: 0.1 Beta (Raport)" /D "D:\Statistic Portal" "%__AppDir__%cmd.exe" /D /T:07 /C ""D:\Statistic Portal\libraries\bin\java.exe" -Xms2G -Xmx3G -jar raportgmin.jar --server.port=9090"
Obviously you have the possibility of changing the /C
option to /K
to keep the window open on completion显然,您可以将
/C
选项更改为/K
以保持 window 在完成时打开
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.