I'm using visual basic programs to create some files for my work, however, I'm learning python and want to use it to shut down my windows system after the visual basic program is completed execution
Asked
Active
Viewed 89 times
1 Answers
0
For this, you must start the process using the Python script since it can not detect the program closing.
Here is the code you need:
import subprocess
import os
process_name = "C:\Windows\System32\Cmd.exe" # Replace this with the directory to your file
# Start the process
process = subprocess.Popen(process_name)
# Wait for the process to finish and shut down
process.wait()
print("Process done, shutting down!")
os.system("shutdown /s /t 1") # Shut down

NoveeX
- 21
- 4