Closing iexplore.exe

This topic contains 2 replies, has 3 voices, and was last updated by Profile photo of Daniel Krebs Daniel Krebs 7 months ago.

  • Author
    Posts
  • #60928
    Profile photo of John
    John
    Participant

    Hi. I am totally new to powershell, just starting to learn it. I'm trying to deploy Java through SCCM 2012. I want to create a script that will check if IE is running on a pc, & if so, display a message that IE will be shutdown in a given amount of time in order for the Java install to complete. After doing some searching I found a script that looks like it will do what I need it to however it gives errors when I run it saying there are syntax errors. If anyone could assist with getting this working below it would be greatly appreciated.

    Dim oShell
    Set oShell = WScript.CreateObject("WScript.Shell")
    Set colProcessList = GetObject("Winmgmts:").ExecQuery ("Select * from Win32_Process")

    For Each objProcess in colProcessList ' Loop checks all running processes and sets vFound to True if it finds iexplore.EXE running.
    If objProcess.name = "iexplore.exe" then
    vFound = True
    End if
    Next
    If vFound = True then
    oShell.Popup "Closing IE" & vbCrLf & vbCrLf & "Click OK if you are ready to continue now.",30,"Software Update"
    oShell.Run "taskkill /F /IM iexplore.exe", 1, True
    End If

  • #60931
    Profile photo of Olaf Soyk
    Olaf Soyk
    Participant

    Sorry. That's not Powershell – it is VBScript.

    Anyway when you post code in a forum you should format it as code. And when you have errors you should post the errors as well.

  • #60936
    Profile photo of Daniel Krebs
    Daniel Krebs
    Moderator

    Olaf is correct the script you've posted is VBScript not PowerShell. I can highly recommended to watch the Getting Started with PowerShell series on Channel 9: https://channel9.msdn.com/Series/GetStartedPowerShell3

    However, checkout the examples of the PowerShell cmdlets Get-Process and Stop-Process on the following pages:

    https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.management/get-process
    https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.management/stop-process

    You can re-create the popup with below lines of PowerShell:

    $shell = New-Object -ComObject WScript.Shell
    $shell.Popup("Closing IE`r`rClick OK if you are ready to continue now.", 30, 'Software Update')
    

    I hope that helps. Otherwise Bing and Google are your friend too.

You must be logged in to reply to this topic.