首页 > 解决方案 > How to execute .exe tool with argument using Powershell script?

问题描述

I want to execute a tool with some argument. I use powershell script to execute it. When I execute the powershell script, it works. But when I use other powershell script to call the first script, it can not work only the part of executing the tool.

This is the first script to execute the tool. it works, if execute only this script.

$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

This is the second script, I do some process, then call the first script. And it does not work in this part

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

Second Script

#### 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 #######

标签: powershell

解决方案


推荐阅读