powershell - exe批处理脚本到带有参数的powershel中的exe
问题描述
我有一个批处理脚本来自动化一些操作。此代码采用 .osis.xml 文件并将其转换为 Osis 格式,以便在某些圣经程序中阅读。
SET work=D:\Documents\Downloads\Emule-Incoming\osis\
osis2mod %work% - < cei1974.osis.xml
现在我正在尝试将我的批处理脚本转换为 PS 脚本。到目前为止,这是我正在做的事情:
# $work variable contains the path of the folder with the original files.
$work = "D:\Documents\Downloads\Emule-Incoming\osis"
# $bpc variable contains the path of destination of CONF files for BPBiblePortable
$bpc = "D:\Documents\Downloads\Emule-Incoming\BPBiblePortable\App\BPBible\resources\mods.d\"
# $xic contains the path of destination of CONF files for xiphos
$xic = "C:\Users\Emanuele\AppData\Roaming\Sword\mods.d\"
# $bpo contains the path of destination of OSIS files for BPBiblePortable
$bpo = "D:\Documents\Downloads\Emule-Incoming\BPBiblePortable\App\BPBible\resources\modules\texts\rawtext\"
# $xio variablecontains the path of destination of OSIS files for xiphos.
$xio = "C:\Users\Emanuele\AppData\Roaming\Sword\modules\texts\rawtext\"
# $Confile Array contains the names of .conf files.
$Confile = @('cei1971.conf', 'cei1974.conf', 'cei2008.conf', 'tilc.conf', 'novav.conf')
foreach ($element in $Confile)
{
# The copy of the files goes well
Copy-Item -Path $work\$element -Destination $bpc
$wshell = New-Object -ComObject Wscript.Shell
$count = 1
$result = 0
While ($result -eq 0)
{
$result = $wshell.Popup("Copiato in $bpc",1,"$element",0)
$count += 1
Write-Host $count
if($count -eq 10)
{
Exit
}
}
Copy-Item -Path $work\$element -Destination $xic
$wshell = New-Object -ComObject Wscript.Shell
$count = 1
$result = 0
While ($result -eq 0)
{
$result = $wshell.Popup("Copiato in $xic",1,"$element",0)
$count += 1
Write-Host $count
if($count -eq 10)
{
Exit
}
}
}
# The name of the .exe.
$eseguibile = "osis2mod.exe"
#
# THIS IS THE COMMAND I'M NOT ABLE TO "translate" in PS
# The problem is that PS not recognize the "- <" passing
#
& $PSScriptRoot\$eseguibile --% $work\ - < $work\cei1974.osis.xml
有人找到像我这样的人吗?
解决方案
推荐阅读
- python - 如何使用 pySpark 使多个 json 处理更快?
- c# - 新年混沌HackerRank练习题-C#解法优化
- php - strftime(): 中文、俄文和匈牙利文编码错误
- javascript - 如何使用幻灯片加载 html 页面
- c++ - 使用 cmake 构建 c++ 时处理 #import (tlh)
- javascript - Javascript 将我的 Node6 Firebase 函数移动到 Node8 异步/等待模式
- python - 在函数中返回多个值时出现问题?
- docker - Docker 标记在 Bitbucket 管道中的步骤之间丢失
- c# - 访问路径被拒绝 - Magick.NET.net40.7.4.3.0
- azure - Powershell 函数输出的变量属性未按预期工作