我们公司希望轻松地将我们的Java Server应用程序安装为Windows服务,因此我们使用YAJSW来封装应用程序。 为了使它更方便一些,我创build了一些小批量脚本,只需要点击安装/卸载/启动/停止服务。
安装,启动和停止工作正常,但使用卸载时,我收到一个错误,找不到一些文件。 他们都使用相同的包assembly置和所有batch file在同一个地方,那么怎么能find一个文件,但其他人不能?
这是我的文件夹结构:
lib |---YAJSW |----bat | |--- installService.bat | |--- uninstallService.bat | |--- and so on |----conf |--- wrapper.conf MyApplication.jar installService.bat //Basically a proxy batch doing some other stuff and then calling the original installService.bat uninstallService.bat //Also a proxy startService.bat //Proxy stopService.bat //Proxy
这些是原始文件中的两个,其中一个是工作文件,另一个是失败的文件:
从Windows服务枚举打开的窗口
Windows服务中的WCF主机:System.Net.WebException:远程服务器返回错误:(404)未find
通过WCF中的命名pipe道将消息从Windows服务logging到应用程序
无法使用WiX启动Windows服务
语音识别循环
这里是uninstallService.bat :
pushd %~dp0 call setenv.bat %wrapper_bat% -r %conf_file% popd
这里是installService.bat :
pushd %~dp0 call setenv.bat %wrapper_bat% -i %conf_file% popd
如果有人想知道%conf_file%来自哪里,就像setenv.bat一样,为运行这些任务所需的其他东西。
它们是一样的,除了一个是通过-r而不是-i 。
无论如何,这些是我的代理文件:
installService.bat工作正常:
::Make a clean copy of our default config xcopy /y /Q libYAJSWconfwrapper.conf.default libYAJSWconfwrapper.conf ::Set current workingdirectory to current executing directory SET workingdir=%cd% ::Replace all backslashes with 4 backslashes to keep YAJSW functioning SET workingdirFixed=%workingdir:=/% ::Set the working directory to the variable that we set up before echo wrapper.working.dir=%workingdirFixed% >> libYAJSWconfwrapper.conf ::Call the install batch file which uses the config that we have created call libYAJSWbatinstallService.bat
和不工作的uninstallService.bat :
call stopService.bat call libYAJSWbatuninstallService.bat
我真的不知道这里有什么错,希望有人能帮忙。
编辑:
setenv.bat:
@echo off rem quotes are required for correct handling of path with spaces rem default java home set wrapper_home=%~dp0/.. rem default java exe for running the wrapper rem note this is not the java exe for running the application. the exe for running the application is defined in the wrapper configuration file set java_exe="java" set javaw_exe="javaw" rem location of the wrapper jar file. necessary lib files will be loaded by this jar. they must be at <wrapper_home>/lib/... set wrapper_jar="%wrapper_home%/wrapper.jar" set wrapper_app_jar="%wrapper_home%/wrapperApp.jar" rem setting java options for wrapper process. depending on the scripts used,the wrapper may require more memory. set wrapper_java_options=-Xmx30m -Djna_tmpdir="%wrapper_home%/tmp" -Djava.net.preferIPv4Stack=true rem wrapper bat file for running the wrapper set wrapper_bat="%wrapper_home%/bat/wrapper.bat" set wrapperw_bat="%wrapper_home%/bat/wrapperW.bat" rem configuration file used by all bat files set conf_file="%wrapper_home%/conf/wrapper.conf" rem default configuration used in genConfig set conf_default_file="%wrapper_home%/conf/wrapper.conf.default"
wrapper.bat:
echo %java_exe% %wrapper_java_options% -jar %wrapper_jar% %1 %2 %3 %4 %5 %6 %7 %8 %9 %java_exe% %wrapper_java_options% -jar %wrapper_jar% %1 %2 %3 %4 %5 %6 %7 %8 %9
Windows服务不执行代码
Windows快速移动时改变光标
使用installutil从具有多个服务的可执行文件安装单个服务
GetmodulefileName始终在服务中返回小写
如何在C#中使用Windows服务调用Windows应用程序?
我发现这个问题,问题是,在uninstallScript.bat我已经使用了两次call ,第一个调用改变了工作目录,因为我正在处理相对路径秒调用解决路径有问题。
为了解决这个问题,我在当前目录中插入了一个pushd作为参数,并在第一次call popd 。
该文件现在看起来像这样:
pushd %~dp0 call stopService.bat popd call libYAJSWbatuninstallService.bat
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。