如何获得从执行批处理文件值 [英] How to get values from an executed batch file

查看:140
本文介绍了如何获得从执行批处理文件值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个准系统回旋的设置,有一些触动。我试图在一个中心位置使用回旋集合中的值,而不是每次部署批处理脚本(这是一个痛苦的屁股)。然而,当我引用 SetupVal.bat 从每个批次的部署,它设置值,但只是停止执行部署脚本。我不知道它为什么不坚持下去,它真的讨厌我了。

这是我的 SetupVal.bat

  SET product.name =####
SET database.name =%product.name%.DB
SET sql.files.directory =.. \\ DB \\ SQLServer的
SET server.database =(本地)\\ SQLEX $ P $干燥综合征
SET repository.path =混帐@ roconnor:%product.name%的.git
SET version.file =_ BuildInfo.xml
SET version.xpath =// buildInfo /版
设置环境=本地

这是我的剧本之一( Local.DBDeployment.bat

 关闭@echoCD ..
SetupVal.bat
CD部署
REM这是为了确保路径是否正确设置了CD%%\\控制台\\ rh.exe/d=%database.name% /f=%sql.files.directory% /s=%server.database% /vf=%version.file% / VX =%版本.xpath%/r=%repository.path% / ENV =%环境%/简单暂停

这是输出当我运行 Local.DBDeployment.bat

  C:\\ dev的\\数据库> SetupValues​​.batC:\\ dev的\\数据库> SET product.name =####C:\\ dev的\\数据库> SET database.name =####DBC:\\ dev的\\数据库> SET sql.files.directory =.. \\ DB \\ SQLServer的C:\\ dev的\\数据库> SET server.database =(本地)\\ SQLEX $ P $干燥综合征C:\\ dev的\\数据库> SET repository.path =混帐@ roconnor:混帐####C:\\ dev的\\数据库>设置version.file =_ BuildInfo.xmlC:\\ dev的\\数据库>设置version.xpath =// buildInfo /版C:\\ dev的\\数据库>设置环境=本地

最后,这是我的目录结构:

 数据库(根)
|
 \\ _db(SQL脚本在这里)
 | _deployment(BAT脚本在此)
 | _settings(忽略的内容)
 | _SetupVal.bat(这里设置的值)


解决方案

在执行 SetupVal.bat ,控制权将交给该文件。没有回报,所以如果 setval.bat 结束后,整批结构结束。相反,打电话给你的文件:

 通话SetupVal.bat

您最初的批处理文件将继续与下一行,当 setupval.bat 结束并返回控制

I'm trying to set up a barebones roundhousE setup, with a few touches. I'm trying to make the values used by roundhousE set in one central location, instead of each deployment batch script (which is a pain in the arse). However, when I reference the SetupVal.bat from each deployment batch, it sets the values but just stops executing the deployment script. I'm not sure why it doesn't carry on, and it's really annoying me.

This is my SetupVal.bat:

SET product.name="####"
SET database.name="%product.name%.DB"
SET sql.files.directory="..\db\SQLServer"
SET server.database="(local)\SQLEXPRESS"
SET repository.path="git@roconnor:%product.name%.git"
SET version.file="_BuildInfo.xml"
SET version.xpath="//buildInfo/version"
SET environment="LOCAL"

this is one of my scripts (the Local.DBDeployment.bat):

@echo off

cd ..
SetupVal.bat
cd deployment
REM this is to make sure the path is correctly set out

"%cd%\Console\rh.exe" /d=%database.name% /f=%sql.files.directory% /s=%server.database% /vf=%version.file% /vx=%version.xpath% /r=%repository.path% /env=%environment% /simple

pause

This is the output when I run Local.DBDeployment.bat:

C:\dev\Database>SetupValues.bat

C:\dev\Database>SET product.name="####"

C:\dev\Database>SET database.name=""####".DB"

C:\dev\Database>SET sql.files.directory="..\db\SQLServer"

C:\dev\Database>SET server.database="(local)\SQLEXPRESS"

C:\dev\Database>SET repository.path="git@roconnor:"####".git"

C:\dev\Database>SET version.file="_BuildInfo.xml"

C:\dev\Database>SET version.xpath="//buildInfo/version"

C:\dev\Database>SET environment="LOCAL"

And finally, this is my directory structure:

Database (root)
|
 \_db (SQL scripts are here)
 |_deployment (bat scripts are here)
 |_settings (ignoring contents)
 |_SetupVal.bat (This sets the values)

解决方案

when you execute SetupVal.bat, control is given to that file. there is no return, so if setval.bat ends, the complete batch-structure ends. Instead call your file:

call SetupVal.bat

Your initial batchfile will continue with the next line, when setupval.bat ends and returns control

这篇关于如何获得从执行批处理文件值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆