blez's : blog

code / design / music and more

Get exe path from process

Leave a comment

        private string GetProcessPath(Process process) {
            using (var searcher = new ManagementObjectSearcher("SELECT ProcessId, ExecutablePath FROM Win32_Process WHERE ProcessId = " + process.Id.ToString())) {
                using (var results = searcher.Get()) {
                    var mo = results.Cast<ManagementObject>().FirstOrDefault();
                    if (mo != null) return (string) mo["ExecutablePath"];
                }
            }

            return null;
        }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s