Abort in NonInteractive Mode if a specified process is running

Hey community,

I cant find an option or command to abort the installation if a specified process, eg. iexplore.exe is running. In Interactive mode the command Show-InstallationWelcome can hold some process names. But it wont ask if the script runs in NonInteractive mode. In this case all named processes will be closed. But I want to abort the script OR also ask the user to close the apps in NonInteractive mode…

Is that possible somehow?

As I see it, the whole purpose of NonInteractive mode is to have the toolkit running without the user interaction… So in the show-installationwelcome would do it’s thing without making the user aware.

Try this in the PREINSTALLATION Section

<code>
if($IsProcessUserInteractive -ne $True -and (Get-Process iexplore -ErrorAction SilentlyContinue)){
    Exit-Script -ExitCode 69696
}
</code>

If using the CloseApps parameter in Show-InstallationWelcome, do not add iexplore to the list of apps to close as this would exit IE and the If statement would always be untrue…

The variable $IsProcessUserInteractive is created by the toolkit, but I haven’t tested it out so I’m not totally sure this will work… And the exitcode could be any number really, but the 69000 - 69999 are recommended for custom exit codes.

Thx Pelle,

its a good idea! But it wont work with your code. Because $IsProcessUserInteractive is still $true if $DeployMode=‘NonInteractive’. Seems to be ‘Silent’…

Thats the code I use now:

<code>
if($DeployMode -eq &#039;NonInteractive&#039; -and (Get-Process iexplore -ErrorAction SilentlyContinue))
{
	Write-Log -Message &amp;quot;Abort: iexplore is running&amp;quot; -Severity 3
	Exit-Script -ExitCode 69696
}
</code>

But your hint was gold :slight_smile:

I see. Well happy you found your way around it. You should probably (just for the sake of it) add -or $DeployMode -eq “Silent” as well then :)…

if($DeployMode -eq "NonInteractive" -or $DeployMode -eq "Silent" -and (Get-Process iexplore -ErrorAction SilentlyContinue))