Partage
  • Partager sur Facebook
  • Partager sur Twitter

kill process "Iexplore.exe" mode silence install

kill process "Iexplore.exe" mode silence install

Sujet résolu
11 août 2019 à 21:29:07

Bonjour

Je cherche une solution pour kill un process en particulier "Iexplore.exe" car lors de l'installation de "System Explorer" en mode silence install celui ci ouvre tous de même une page IE explore vers le site de l’éditeur du logiciel et tant que cette page internet n'est pas fermé le process d'installation ou désinstallation ne continu pas ce qui engendre un arrêt des script jusqu’à intervention humaine (fermeture de la page interne) pour que celui ci continu de s’exécuter normalement.

Donc je cherche une méthode par exemple permettant de démarrer l'installation ou la désinstallation de "System Explorer" et en "arrière plan" un script me permettant de détecter si "Iexplore.exe" est ouvert toutes les x second ou alors un script qui au bout de 120 second par exemple kill tous process "Iexplore.exe" actif qui bloquerais la suite de l'install ou désinstallation de "System Explorer".

# Script install App MDT
# ----------- Modifier variable apres cette ligne -----------
# ------------- Modify variable after this line -------------

$NameApp = "SystemExplorer"
$Installer32 = "SystemExplorerSetup.exe"
$Installer64 = "SystemExplorerSetup.exe"
$arguments = "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-"
$uninstaller32or64 = "System Explorer\unins000.exe"
$argumentsUninstall = "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-"

# --------------- Ne rien modifier apres cette ligne ---------------
# ------------- Do not modify anything after this line -------------

$SourceConfigSystemExplorer = "$(Get-Location)\ConfigProgramData\SystemExplorer"
$DestinationConfigSystemExplorer = "C:\ProgramData\SystemExplorer"

Write-Host "Debut installation $NameApp" -ForegroundColor Green
function CopyFilesToFolder ($fromFolder, $toFolder) {
    # Make sure the destination folder exists
	If(!(Test-Path $toFolder)){New-Item $toFolder -ItemType Directory -Force|Out-null}
	# Copy source folder contents to destination folder recursively
	Copy-Item "$fromFolder\*" -Destination "$toFolder" -recurse -force
}

# Uninstall
Write-Host "Uninstall $NameApp" -ForegroundColor Cyan
If ((Test-Path "${env:ProgramFiles(x86)}\Notepad++\uninstall.exe" -PathType Leaf) -or (Test-Path "${Env:ProgramFiles}\Notepad++\uninstall.exe" -PathType Leaf))
{
	If (Test-Path "${env:ProgramFiles(x86)}\$uninstaller32or64" -PathType Leaf)
	{
		Write-Host "TEST Desinstallation $NameApp ProgramFilesX86" -ForegroundColor Magenta
		$executableSupprFinal = "${env:ProgramFiles(x86)}\$uninstaller32or64"
		start-process $executableSupprFinal $argumentsUninstall -PassThru -Verb RunAs -Wait #-NoNewWindow
		Write-Host "Desinstallation $NameApp reussi" -ForegroundColor Yellow
	}
	elseif (Test-Path "${Env:ProgramFiles}\$uninstaller32or64" -PathType Leaf)
	{
		Write-Host "TEST Desinstallation $NameApp ProgramFiles" -ForegroundColor Magenta
		$executableSupprFinal = "${env:ProgramFiles}\$uninstaller32or64"
		start-process $executableSupprFinal $argumentsUninstall -PassThru -Verb RunAs -Wait #-NoNewWindow
		Write-Host "Desinstallation $NameApp reussi" -ForegroundColor Yellow
	}
	else
	{
		Write-Host "Desinstaller $NameApp introuvable" -ForegroundColor Red
	}
}
else
{
	Write-Host "$NameApp NON presente" -ForegroundColor Green
}


# Install
Write-Host "Installation $NameApp" -ForegroundColor Cyan
If (Test-Path "${env:ProgramFiles(x86)}")
{
	$Installer = $Installer64
	$InstallerFinal = "$(Get-Location)\$Installer"
	start-process $InstallerFinal $arguments -PassThru -Verb RunAs -Wait #-NoNewWindow
}
Else 
{
	$Installer = $Installer32
	$InstallerFinal = "$(Get-Location)\$Installer"
	start-process $InstallerFinal $arguments -PassThru -Verb RunAs -Wait #-NoNewWindow
}

#Copy Config Item from Deployroot
Start-Sleep -Seconds 10
Write-Host "Copie auxiliere $NameApp" -ForegroundColor Cyan
CopyFilesToFolder "$SourceConfigSystemExplorer" "$DestinationConfigSystemExplorer"

Write-Host "Fin install $NameApp" -ForegroundColor Green


Edit le 2019-08-17 à 02-20 :

Je viens de trouver qu'il était possible de lancer en parallèle des "Jobs" powershell si quelqu'un peux m'indiquer comment je peux utiliser cela pour avoir un job avec un timeout par exemple qui fonctionnerai en même temps que l'installation ou la désinstallation.

Merci

-
Edité par Vincent1890 12 août 2019 à 2:23:53

  • Partager sur Facebook
  • Partager sur Twitter
13 août 2019 à 4:53:52

Apres pas mal de test avec les workflows powershell sans résultat malheureusement.

Je me suis concentré sur les jobs powershell et cela a résolu mon souci alors voici l'auto réponse a cette demande.

# Script install App MDT
# ----------- Modifier variable apres cette ligne -----------
# ------------- Modify variable after this line -------------

$NameApp = "SystemExplorer"
$Installer32 = "SystemExplorerSetup.exe"
$Installer64 = "SystemExplorerSetup.exe"
$arguments = "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-"
$uninstaller32or64 = "System Explorer\unins0**.exe"
$argumentsUninstall = "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-"

# --------------- Ne rien modifier apres cette ligne ---------------
# ------------- Do not modify anything after this line -------------

$SourceConfigSystemExplorer = "$(Get-Location)\ConfigProgramData\SystemExplorer"
$DestinationConfigSystemExplorer = "C:\ProgramData\SystemExplorer"
$StartJob1 = "1" # $StartJob = "0" or "1"
$NameJob = "StopIE"
$ProcName = "iexplore"


Write-Host "Debut installation $NameApp" -ForegroundColor Green
function CopyFilesToFolder ($fromFolder, $toFolder) {
    # Make sure the destination folder exists
	If(!(Test-Path $toFolder)){New-Item $toFolder -ItemType Directory -Force|Out-null}
	# Copy source folder contents to destination folder recursively
	Copy-Item "$fromFolder\*" -Destination "$toFolder" -recurse -force
}

function StartJob1PowerShell($NameJob1, $ProcName1) {
    Start-Job -Name "$NameJob1" -ScriptBlock {
        while($true) { Get-Process | where {$_.ProcessName -like "$using:ProcName1"} | Stop-Process; Start-Sleep -Seconds 10 }
    } -ArgumentList $ProcName1
}

# Uninstall
Write-Host "Uninstall $NameApp" -ForegroundColor Cyan
If ((Test-Path "${env:ProgramFiles(x86)}\Notepad++\uninstall.exe" -PathType Leaf) -or (Test-Path "${Env:ProgramFiles}\Notepad++\uninstall.exe" -PathType Leaf))
{
	If (Test-Path "${env:ProgramFiles(x86)}\$uninstaller32or64" -PathType Leaf)
	{
		Write-Host "TEST Desinstallation $NameApp ProgramFilesX86" -ForegroundColor Magenta
		If ($StartJob1 -eq "1"){ StartJob1PowerShell "$NameJob" "$ProcName"}
		$executableSupprFinal = "${env:ProgramFiles(x86)}\$uninstaller32or64"
		start-process $executableSupprFinal $argumentsUninstall -PassThru -Verb RunAs -Wait #-NoNewWindow
		Write-Host "Desinstallation $NameApp reussi" -ForegroundColor Yellow
	}
	elseif (Test-Path "${Env:ProgramFiles}\$uninstaller32or64" -PathType Leaf)
	{
		Write-Host "TEST Desinstallation $NameApp ProgramFiles" -ForegroundColor Magenta
		If ($StartJob1 -eq "1"){ StartJob1PowerShell "$NameJob" "$ProcName"}
		$executableSupprFinal = "${env:ProgramFiles}\$uninstaller32or64"
		start-process $executableSupprFinal $argumentsUninstall -PassThru -Verb RunAs -Wait #-NoNewWindow
		Write-Host "Desinstallation $NameApp reussi" -ForegroundColor Yellow
	}
	else
	{
		Write-Host "Desinstaller $NameApp introuvable" -ForegroundColor Red
	}
}
else
{
	Write-Host "$NameApp NON presente" -ForegroundColor Green
}
# Suppression du Job créer
If ($StartJob1 -eq "1") {
	If ( [bool](get-job -Name $NameJob -ea silentlycontinue) ) {
		Remove-Job -Name $NameJob -Force
	}
	Start-Sleep -Seconds 5
}

# Install
Write-Host "Installation $NameApp" -ForegroundColor Cyan
If (Test-Path "${env:ProgramFiles(x86)}")
{
	If ($StartJob1 -eq "1"){ StartJob1PowerShell "$NameJob" "$ProcName"}
	$Installer = $Installer64
	$InstallerFinal = "$(Get-Location)\$Installer"
	start-process $InstallerFinal $arguments -PassThru -Verb RunAs -Wait #-NoNewWindow
}
Else 
{
	If ($StartJob1 -eq "1"){ StartJob1PowerShell "$NameJob" "$ProcName"}
	$Installer = $Installer32
	$InstallerFinal = "$(Get-Location)\$Installer"
	start-process $InstallerFinal $arguments -PassThru -Verb RunAs -Wait #-NoNewWindow
}
# Suppression du Job créer
If ($StartJob1 -eq "1") {
	If ( [bool](get-job -Name $NameJob -ea silentlycontinue) ) {
		Remove-Job -Name $NameJob -Force
	}
	Start-Sleep -Seconds 5
}

# Copy Config Item from Deployroot
Start-Sleep -Seconds 2
Write-Host "Copie auxiliere $NameApp" -ForegroundColor Cyan
CopyFilesToFolder "$SourceConfigSystemExplorer" "$DestinationConfigSystemExplorer"

Write-Host "Fin install $NameApp" -ForegroundColor Green

Donc voila cela pourra surement être utile a d'autre personne comme moi souhaitant installer un logiciel en mode silent install (Install grace a MDT dans mon cas) alors que des fenêtre intempestive et bloque la fin du process ce lances.

Edit le 2019-09-14 à 02H57

Je viens de faire une version final de la partie fonction "StartJob1PowerShell" j'ai donc modifier les scripts du post comme cela le lancement de Job peux être générique et utilisable dans plus d'environnement.

-
Edité par Vincent1890 14 août 2019 à 3:03:01

  • Partager sur Facebook
  • Partager sur Twitter