powershell - 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 #######
解决方案
推荐阅读
- python-3.x - 将图像加载到 TKinter Canvas 小部件时的奇怪行为
- ruby - 为使用 Ruby 上传的对象设置 AWS S3 存储类
- angular - ng test 和 ng serve 失败并显示“发生未处理的异常:无效或意外的令牌”
- sql - SQL - 13 个数字列的组合如何等于 1 列
- javascript - 如何使用ajax get rest api从aws s3获取对象
- python - 如何使用 Selenium 和 Python 从通过 xpath 找到的 webdriver 元素中提取文本
- javascript - 如何仅从第一页和最后一页删除按钮?
- javascript - 从 html 模板字符串中删除额外的元素
- model-view-controller - MVC 文件夹结构和用例中操作的最佳实践
- sql-server - 用 ssis 中的用户变量覆盖表达式中的 zip 文件