title: How to get the exact path of notepad.exe in order to associate a file extension
body: <p>I need to associate a file extension I have created “.rulog” with notepad.exe as part of a setup project installation for a windows 7 machine (it’s here since we require admin privileges to write to the registry). </p>
  
  <p>Basically I need to obtain programmatically the exact path of the notepad.exe. Now, I understand that it typically lives in C:\Windows\system32. This is part of PATH system environment variable, so I guess I could loop through all the PATH variables and test if “notepad.exe” exists by combining “notepad.exe” with the current path using File.Exists. However this feels very clumsy. </p>
  
  <p>Essentially I need to add an entry to </p>
  
  <pre><code>Computer\HKEY_CLASSES_ROOT\.rulog\shell\open\command\ 
  </code></pre>
  
  <p>with the value of the path of notepad.</p>
  
  <p>Incidentally I can see that .txt in: </p>
  
  <pre><code>Computer\HKEY_CLASSES_ROOT\.txt\ShellNew
  </code></pre>
  
  <p>has a value for ItemName of </p>
  
  <pre><code>“@%SystemRoot%\system32\notepad.exe,-470”
  </code></pre>
  
  <p>Perhaps I can just copy this value? Or is this dangerous?(e.g. does not exist).</p>