带参数的PowerShell中exe批处理脚本到exe
我有一个批处理脚本来自动化一些操作。 这段代码获取一个.osis.xml文件,并将其转换为osis格式,以便在一些圣经程序中读取带参数的PowerShell中exe批处理脚本到exe,powershell,batch-file,powershell-2.0,powershell-3.0,powershell-4.0,Powershell,Batch File,Powershell 2.0,Powershell 3.0,Powershell 4.0,我有一个批处理脚本来自动化一些操作。 这段代码获取一个.osis.xml文件,并将其转换为osis格式,以便在一些圣经程序中读取 SET work=D:\Documents\Downloads\Emule-Incoming\osis\ osis2mod %work% - < cei1974.osis.xml SET work=D:\Documents\Downloads\Emule Incoming\osis\ osis2mod%工作%-
SET work=D:\Documents\Downloads\Emule-Incoming\osis\
osis2mod %work% - < cei1974.osis.xml
SET work=D:\Documents\Downloads\Emule Incoming\osis\
osis2mod%工作%-
现在我尝试将批处理脚本转换为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
#$work变量包含包含原始文件的文件夹路径。
$work=“D:\Documents\Downloads\Emule-Incoming\osis”
#$bpc变量包含BPBiblePortable的CONF文件的目标路径
$bpc=“D:\Documents\Downloads\Emule-Incoming\BPBiblePortable\App\BPBible\resources\mods.D\”
#$xic包含xiphos的CONF文件的目标路径
$xic=“C:\Users\Emanuele\AppData\Roaming\swarm\mods.d\”
#$bpo包含BPBiblePortable的OSI文件的目标路径
$bpo=“D:\Documents\Downloads\Emule-Incoming\BPBiblePortable\App\BPBible\resources\modules\text\rawtext\”
#$xio variable包含xiphos的OSI文件的目标路径。
$xio=“C:\Users\Emanuele\AppData\Roaming\swarm\modules\text\rawtext\”
#$Confile数组包含.conf文件的名称。
$Confile=@('cei1971.conf','cei1974.conf','cei2008.conf','tilc.conf','novav.conf')
foreach($Confile中的元素)
{
#这些文件的副本很好
复制项目-路径$work\$element-目标$bpc
$wshell=新对象-ComObject Wscript.Shell
$count=1
$result=0
While($result-eq 0)
{
$result=$wshell.Popup(“Copiato in$bpc”,1,“$element”,0)
$count+=1
写入主机$count
如果($计数-等式10)
{
出口
}
}
复制项目-路径$work\$element-目标$xic
$wshell=新对象-ComObject Wscript.Shell
$count=1
$result=0
While($result-eq 0)
{
$result=$wshell.Popup(“Copiato in$xic”,1,“$element”,0)
$count+=1
写入主机$count
如果($计数-等式10)
{
出口
}
}
}
#.exe的名称。
$eseguibile=“osis2mod.exe”
#
#这是我无法在PS中“翻译”的命令
#问题是PS无法识别“--<$work\cei1974.osis.xml
是不正确的,是吗?语法应该是osis2mod.exe[OPTIONS]
,其中
可以是已验证的osis文档的路径
,(在这种情况下,我假设$work\cei1974.osis.xml
),或-
,从标准输入中读取。因此,我怀疑您是否应该同时规定这两个方面。您可能应该只使用$OsisDoc=“$work\cei1974.osis.xml”
,然后使用和$PSScriptRoot\$eseguibile$outFolder$OsisDoc
。我可能会从$outFolder=“$work>中删除尾部的反斜杠\“
也是。您可以使用$args
,它应该传递参数properly@Compo不,如wiki:“参数和选项”部分所示,-<$work\cei1974.osis.xml
是@EmanueleTinari的正确方式,您是说$work\cei1974.osis.xml
不是一个经过验证的osis文档吗?无论如何,您似乎将-<$work\cei1974.osis.xml
视为单个字符串参数,而不是参数列表<代码>-
是一个选项@冷静,你说得对!我在没有-
和
d:\Documents\Downloads\Emule Incoming\OSI\CreaOsis.ps1您正在运行osis2mod:$Rev:2893$SUCCESS:d:\Documents\Downloads\Emule Incoming\osis2mod\osis2mod.exe:已经完成了它的工作,现在将休息PS C:\Users\Emanuele>Tnx很多,@Compo