i was writing a python script and i got the idea of making a line of code that closes the visual studio code window is there a way to do this with "just" python commands or do you need an other language for this?
Yes, you can use psutil
import psutil
for proc in psutil.process_iter():
if proc.name() == "Process name to kill" : # You can use some regex here too
proc.kill()
Name of the process can depend on platform you work on but if you list all processes with eg ps -A
(or by printing them with psutil) you should be able to find Visual Studio process name.
Assuming you're working on Windows..
import os
os.system("taskkill /f /im code.exe")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.