首页 > 解决方案 > 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

有人找到像我这样的人吗?

标签: powershellbatch-filepowershell-2.0powershell-3.0powershell-4.0

解决方案


推荐阅读