title: Map network drive: "net.exe USE" vs WshNetwork.MapNetworkDrive?
body: <p>I'm looking to map a drive in my program. My users can be using every version of Windows from XP on up. So I need the most versatile method. I have used the first method before and generally it's worked well for me. But there really isn't way to catch errors with it (that I know of anyway). The second will easily let me wrap a try/catch block around it, but for all the searching I've done for an alternatives to method 1, I've only run across method 2 once. So that leaves me to wonder if its reliable enough for such a varied environment. Can anyone tell me if method 2 is safe for most circumstances?</p>
  
  <p>Method 1</p>
  
  <pre><code>Process.Start("net.exe", @"USE Z: \\server\share /user:domain\username password").WaitForExit();
  </code></pre>
  
  <p>Method 2 referencing the Windows Script Host Object Model</p>
  
  <pre><code>IWshNetwork_Class network = new IWshNetwork_Class(); 
  network.MapNetworkDrive("k:", @"\\server\share");
  </code></pre>