23-08-21 02:17 PM
23-08-21 03:03 PM
Chrome integration works in such a way that (after a fresh reboot), once a Process is run that interacts with Chrome, a connection is made with Chrome over port 31924. Even after that Process has completed, the connection to port 31924 will still be open and is not disposed of.
When performing testing of a Process via Studio/stepping through via Debug mode, the Process is run via the local (private) Resource. As described above, the local Resource would initially open the connection, and that local Resource would then hold on to that connection.
If you subsequently attempt to run the Process from Control Room to a Runtime Resource running locally on the same machine, as the connection had already been opened by the local Resource, a new connection cannot then be initiated, which causes a failure.
So, if this is the cause of the issue then the resolution is to restart the listener or restart the Resource machine. This will free the connection and allow the Process to run again via either Control Room or Studio.
23-08-21 04:15 PM
23-08-21 04:30 PM
24-08-21 07:07 AM
25-08-21 01:19 AM
26-08-21 04:43 AM
27-08-21 01:36 AM
Try
for each p as System.Diagnostics.Process in System.Diagnostics.Process.GetProcessesByName(Process_Name)
p.kill
next
Catch ex As Exception
End Try
It retrieves each p (process) with a name of (input process name) and tells it to kill it in a loop as there may be multiple instances of a process launched. Eg. launch chrome or edge manually and open task manager, I'll bet you find numerous process with differing PID's listed.'Preset Message and Success
Message = vbNullString
Success = False
Dim TimeOutWatch As Stopwatch
TimeOutWatch = New Stopwatch
Try
'Catch Bad Input Data
If String.IsNullOrWhiteSpace(Process_Name) Then
Throw New Exception("Process Name to kill was blank.")
End If
If Time_Out = TimeSpan.Zero Then
Throw New Exception("Your entered Time Out timespan is set to 0.")
End If
'Attempt a cleaner close first.
'Only execute Close if there is something to Close
'the following line will count existing processes with Process_Name
If Process.GetProcessesByName(Process_Name).Length > 0 Then
'Start the stopwatch to count for timeout condition
TimeOutWatch.Start()
'Loop through all the processes of Process_Name
For Each p As Process In Process.GetProcessesByName(Process_Name)
'Check if kill attempt time has elapsed past the requested Time_Out
If TimeOutWatch.ElapsedMilliseconds <= CLng(Time_Out.TotalMilliseconds) Then
'Only attempt to Close the process if it is alive/running
'This if statement checks this condition
If Not p.HasExited() Then
Try
p.CloseMainWindow()
p.Close()
Catch ex As InvalidOperationException
'This means that the process has already exited
Message = (Message + vbCrLf + "The Process has already exited: " + vbCrLf + ex.Message).Trim()
Catch ex As NotSupportedException
'This means that the process is remote
Message = ((Message + vbCrLf + "Cannot Close Remote Process: " + vbCrLf + ex.Message).Trim())
Finally
'Do Nada
End Try
End If
Try
'This will wait a maximum of 5 seconds for the process to exit, the '5000' is milliseconds
p.WaitForExit(5000)
Thread.Sleep(100)
Catch exc As Exception
Finally
'clean the resources used by the process for the Garbage Collector to be able to clear it
p.Dispose()
Thread.Sleep(100)
End Try
Else
'This means the elapsed time during the attempt to Close the process has elapsed past the requested Time_Out
Exit For
End If
Next
End If
Thread.Sleep(1000)
'Try to catch stragglers with a little bit uglier 'kill'
'Only execute kill if there is something to kill
'the following line will count existing processes with Process_Name
If Process.GetProcessesByName(Process_Name).Length > 0 Then
'Loop through all the processes of Process_Name
For Each p As Process In Process.GetProcessesByName(Process_Name)
'Check if kill attempt time has elapsed past the requested Time_Out
If TimeOutWatch.ElapsedMilliseconds <= CLng(Time_Out.TotalMilliseconds) Then
'Only attempt to Kill the process if it is alive/running
'This if statement checks this condition
If Not p.HasExited() Then
Try
p.Kill()
Catch ex As System.ComponentModel.Win32Exception
'This means that the process was terminating or can't be terminated - we'll double check later
Message = (Message + vbCrLf + "The process was terminating or cannot be terminated: " + vbCrLf + ex.Message).Trim()
Catch ex As InvalidOperationException
'This means that the process has already exited
Message = (Message + vbCrLf + "The Process has already exited: " + vbCrLf + ex.Message).Trim()
Catch ex As NotSupportedException
'This means that the process is remote
Message = ((Message + vbCrLf + "Cannot Kill Remote Process: " + vbCrLf + ex.Message).Trim())
Finally
'Do Nada
End Try
End If
Try
'This will wait a maximum of 5 seconds for the process to exit, the '5000' is milliseconds
p.WaitForExit(5000)
Thread.Sleep(100)
Catch exc As Exception
Finally
'clean the resources used by the process for the Garbage Collector to be able to clear it
p.Dispose()
Thread.Sleep(100)
End Try
Else
'This means the elapsed time during the attempt to kill the process has elapsed past the requested Time_Out
Exit For
End If
Next
End If
Catch ex As Exception
Message = (Message + vbCrLf + ex.Message).Trim()
Finally
'Continue to wait for requested timeout to elapse if we haven't established success
While TimeOutWatch.ElapsedMilliseconds < CInt(Time_Out.TotalMilliseconds) And Not Success
If Process.GetProcessesByName(Process_Name).Length <= 0 Then
Success = True
End If
End While
'Final Success Check before exiting
If Not String.IsNullOrWhiteSpace(Process_Name) AndAlso Not Time_Out = TimeSpan.Zero AndAlso Process.GetProcessesByName(Process_Name).Length <= 0 Then
Success = True
Message = vbNullString
Else If Not String.IsNullOrWhiteSpace(Process_Name) AndAlso Not Time_Out = TimeSpan.Zero AndAlso Process.GetProcessesByName(Process_Name).Length > 0 Then
Success = False
Message = (Message + vbCrLf + "Remaining # of [" + Process_Name + "] to kill: [" + Process.GetProcessesByName(Process_Name).Length.ToString + "]").Trim()
End If
End Try
Dim preferencesFilePath As String
preferencesFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\Microsoft\Chrome\User Data\Default\Preferences"
If System.IO.File.Exists(preferencesFilePath) Then
Dim preferencesText As String
preferencesText = System.IO.File.ReadAllText(preferencesFilePath)
preferencesText = System.Text.RegularExpressions.Regex.Replace(preferencesText,"(?<=,""exit_type"":"")(.*)(?="",)","Normal")
preferencesText = System.Text.RegularExpressions.Regex.Replace(preferencesText,"(?<=,""exited_cleanly"":)(.*)(?=,)","true")
System.IO.File.WriteAllText(preferencesFilePath,preferencesText)
End If
In this case the example is not really parsing the JSON preferences file but just finding the section it cares about with regex and replacing it with a value the browser understands as 'closed cleanly'31-08-21 09:07 AM
19-09-22 03:50 PM