jxtemp 0 Posted November 20, 2021 Share Posted November 20, 2021 I want use 'run command' tast to install the.exe program. currently, only simple commands can be executed. How do I run powershell commands that include conditions and have multiple quotes like the following? thanks. "$installed = $null $Application = "ABC" $installed = Get-WMIObject -Query "SELECT * FROM Win32_Product Where Vendor Like '%$Application%'" if(!$installed) { $Arguments = @( "AP_ID=7eXXXe-XXXxx" "/install" "/quiet" "/norestart" ) Start-Process "./ABC.exe" -ArgumentList $Arguments -Wait -NoNewWindow Write-Host "$Application was Installed Successfully" } else{ Write-Host "$Application Already Installed: $installed" }" Link to comment Share on other sites More sharing options...
ESET Staff MartinK 375 Posted November 22, 2021 ESET Staff Share Posted November 22, 2021 I would recommend to test locally to find out how to adapt it - what happens when task is executed is that standard BAT file is created with content of task configuration (with some pretty standard encoding-related commands in the beginning), so it is crucial to find out how such BAT file can be created. There are definitely few special characters that has to be escaped to be used in BAT file, for example "%" and possibly also "!". Link to comment Share on other sites More sharing options...
Recommended Posts