Jump to content

Recommended Posts

Posted

    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"
}"
 

eset_RunCommd.png

  • ESET Staff
Posted

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 "!".

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...