我正在尝试运行以下ps1脚本
PowerShell (New-Object System.Net.WebClient).DownloadFile('https://server/file1.exe','file1.exe');Start-Process 'file1.exe'
PowerShell (New-Object System.Net.WebClient).DownloadFile('https://server/file2.exe','file2.exe');Start-Process 'file2.exe'
但是我只能在不运行的情况下下载file1.exe
我该如何下载并执行file1.exe,然后下载并执行file2.exe
谢谢
答案 0 :(得分:0)
尝试提供下载文件的完整路径和文件名。
$file1 = 'D:\Test\file1.exe'
$file2 = 'D:\Test\file2.exe'
$webClient = New-Object System.Net.WebClient
$webClient.DownloadFile('https://server/file1.exe',$file1)
$webClient.DownloadFile('https://server/file2.exe',$file2)
$webClient.Dispose()
然后依次运行可执行文件:
$process = Start-Process $file1 -PassThru
$process.WaitForExit()
$process = Start-Process $file2 -PassThru
$process.WaitForExit()