如何使用Powershell脚本通过参数执行.exe工具?

时间:2019-07-10 09:06:58

标签: powershell

我想执行带有一些参数的工具。我使用powershell脚本执行它。当我执行powershell脚本时,它可以工作。但是,当我使用其他Powershell脚本调用第一个脚本时,它不能仅执行该工具的一部分。

这是执行该工具的第一个脚本。如果仅执行此脚本,它将起作用。

$Path = "C:\Tool"
$IP = 10.1.1.1
Write-Host $IP
$Find = "ABC123"
Write-Host $Find
$Folder = New-Item -ItemType Directory -Force -Path "C:\DW"
& $Path\Assembly.exe --sserver $IP --assembly $Find --localpath $Folder
Start-Sleep -s 1

这是第二个脚本,我做一些处理,然后调用第一个脚本。而且在这部分不起作用

& $Path\Assembly.exe --sserver $IP --assembly $Find --localpath $Folder

第二个脚本

#### Do some process ####
$Button1                         = New-Object system.Windows.Forms.Button
$Button1.BackColor               = "#136aa4"
$Button1.text                    = "OK"
$Button1.width                   = 70
$Button1.height                  = 27
$Button1.location                = New-Object System.Drawing.Point(960,57)
$Button1.Font                    = 'Microsoft Sans Serif,10'
$Button1.AutoSize                = $true
$Button1.ForeColor               = "#ffffff"

$Button1.Add_Click({  

    $result = & ".\Get.ps1" $TextBox1.Text
    Write-Host $result
#---------------------- Download ML -----------------------#
    & ".\DW.ps1" ##### THIS IS MY FIRST SCRIPT TO EXECUTE THE TOOL #####
#----------------------------------------------------------#
    if($result.Length -gt 0){  
        $Global:status = "active" 
        $Button2.Visible = $true
        $Button3.Visible = $true

        $filePath_file = Get-ChildItem "C:\DW\Order0\*.txt"
        $filePath = Get-Content $filePath_file


###### DO Some process #######

0 个答案:

没有答案