I want to get the process id by the process name in windows environment?
I find golang only has the api os.FindProcess(id)
,but no by name.
I want to get the process id by the process name in windows environment?
I find golang only has the api os.FindProcess(id)
,but no by name.
You can list all the processes and match them with the name you want to find, by using the updated sys call package, https://godoc.org/golang.org/x/sys, it has most of the windows api.
func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error)
func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error)
also see the msdn docs: https://msdn.microsoft.com/en-us/library/windows/desktop/ms684834(v=vs.85).aspx