none
Pragmatically Close Edges RRS feed

  • Question

  • I am Pragmatically close Microsoft edges but length is getting be ("Length = 0") I have applied

    Dim Edges() As Process = Process.GetProcessesByName("Microsoft Edge")

    For Each Process As Process In Edges
                Process.Kill()
    Next

    Tuesday, January 7, 2020 2:42 PM

Answers

  • Try using For Next rather than For Each.

    Module Module1
    
        Sub Main()
    
            Dim edges As IEnumerable(Of Process) = Process.GetProcesses().
                    Where(Function(item) item.ProcessName.Contains("Edge"))
    
            For index As Integer = 0 To edges.Count() - 1
                edges(index).Kill()
            Next
        End Sub
    
    End Module
    


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Tuesday, January 7, 2020 3:00 PM
    Moderator

All replies

  • Try using For Next rather than For Each.

    Module Module1
    
        Sub Main()
    
            Dim edges As IEnumerable(Of Process) = Process.GetProcesses().
                    Where(Function(item) item.ProcessName.Contains("Edge"))
    
            For index As Integer = 0 To edges.Count() - 1
                edges(index).Kill()
            Next
        End Sub
    
    End Module
    


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Tuesday, January 7, 2020 3:00 PM
    Moderator
  • Hi, 

    Thank you for posting here.

    According to your code, I make a test on my side and reproduce your problem.

    To solve this problem, Please delete the blank in your string.

    Dim Edges() As Process = Process.GetProcessesByName("MicrosoftEdge")

    Result:

    Hope it can help you.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by CompuTechSide Wednesday, January 8, 2020 11:59 AM
    • Unmarked as answer by CompuTechSide Wednesday, January 8, 2020 2:35 PM
    Wednesday, January 8, 2020 3:20 AM
    Moderator