Skip to content

Instantly share code, notes, and snippets.

@matthewdeanmartin
Last active December 8, 2022 02:56
Show Gist options
  • Save matthewdeanmartin/c93eecae970a3810a915ac85e0ee2457 to your computer and use it in GitHub Desktop.
Save matthewdeanmartin/c93eecae970a3810a915ac85e0ee2457 to your computer and use it in GitHub Desktop.
VB hates itself.
' Declare variables
Dim s As String
Dim fs As Object
Dim f As Object
Dim wmi As Object
Dim processes As Object
Dim process As Object
' Open a new file for writing
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.CreateTextFile("kill_vb6.py", True)
' Write the Python code to kill the VB6 process
s = "import os" & vbCrLf
s = s & "import signal" & vbCrLf
s = s & "import sys" & vbCrLf
s = s & vbCrLf
s = s & "def kill_vb6():" & vbCrLf
s = s & vbTab & "for proc in psutil.process_iter():" & vbCrLf
s = s & vbTab & vbTab & "if proc.name() == 'VB6.EXE':" & vbCrLf
s = s & vbTab & vbTab & vbTab & "os.kill(proc.pid, signal.SIGKILL)" & vbCrLf
s = s & vbTab & vbTab & vbTab & "sys.exit()" & vbCrLf
s = s & vbCrLf
s = s & "if __name__ == '__main__':" & vbCrLf
s = s & vbTab & "kill_vb6()"
f.WriteLine s
' Close the file
f.Close
' Bemoan the existence of VB6
MsgBox "Oh no, I'm a VB6 program!"
' Launch the Python program to kill the VB6 process
Shell "python kill_vb6.py"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment