简体   繁体   English

从任务计划程序启动批处理文件指向 C:\Windows\system32

[英]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
You could possibly have used something like the following idea, to define a title, your working directory, and console color all in one command: 您可能已经使用类似以下的想法,在一个命令中定义标题、工作目录和控制台颜色:
 @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.

相关问题 使用批处理文件将文件从本地文件夹复制到“C:\\ Windows \\ System32 \\” - Copying a file from local folder to “C:\Windows\System32\” using batch file C++ 重命名文件@C:\\Windows\\System32\\Drivers - C++ Rename File @ C:\Windows\System32\Drivers c:\\ windows \\ system32 \\ dns删除.dns文件 - c:\windows\system32\dns deleting .dns file 如何使用命令提示符或批处理文件在主机文件(位于C:/ windows / system32 / drivers / etc文件夹中)中设置文本? - How to set texts in a hosts file (found in C:/windows/system32/drivers/etc folder) using command prompt or a batch file? Windows路径不包含C:\\ WINDOWS \\ system32,可以使用批处理脚本添加它吗? - Windows path doesn't contain C:\WINDOWS\system32, can I add it using batch script? 将system32中的批处理文件目录更改为CMD命令执行点 - Change batch file directory in system32 to CMD command execution point 重新打开 C:\\windows\\system32 中的文件时,ReOpenFile Windows API 失败并显示“错误无效名称” - ReOpenFile Windows API fails with "error invalid name" when reopening a file in C:\windows\system32 如何在Windows 8的路径中添加C:\\ windows \\ system32? - How to add C:\windows\system32 to path on Windows 8? \\ Windows \\ vs. \\ Windows \\ System32 - 文件位置约定 - \Windows\ versus \Windows\System32 - File location conventions 使用32位应用程序C#的Sysnative和%windir%检查System.32中的File.Exists - Check File.Exists in System32 with Sysnative and %windir% from 32-bit app C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM