title: How to set default dbpath for mongoDB in windows 7?
body: <p>I just installed mongoDB in my windows machine</p>
  
  <pre><code>MongoDB version       : Windows 64-bit 2008 R2+ release 3.0.4
  OS Version            : Microsoft Windows 7 Ultimate 64-bit
  Installation Directory: "C:\Program Files\MongoDB"
  </code></pre>
  
  <p>instead of creating the database in default <code>C:\data\db\</code>, I created a directory in the installation directory, i.e. <code>C:\Program Files\MongoDB\data\db</code>. Now I can run <code>mongod</code> server by the command </p>
  
  <pre><code>mongod --dbpath "C:\Program Files\MongoDB\data\db"
  </code></pre>
  
  <p>If I run only <code>mongod</code> it throws an exception saying </p>
  
  <pre><code>[initandlisten] exception in initAndListen: 29 Data directory C:\data\db\ not found., terminating
  </code></pre>
  
  <p>So, apparently the default dbpath is set to <code>C:\data\db\</code>. Each time I run mongod, I have to explicitly specify <code>--dbpath</code></p>
  
  <p>Is there a way to override the default <code>dbpath</code> value? I have tried following <a href="https://stackoverflow.com/a/25303400/1355722">this answer</a>, which solved the issue. But as there were no default <code>mongod.cfg</code> file, now I have to tun the command:</p>
  
  <pre><code>mongod --config "C:\Program Files\MongoDB\mongod.cfg"
  </code></pre>
  
  <p>Which doesn't help much, because now I have to explicitly specify <code>--config</code> each time. All I want to do is just type <code>mongod</code>, each time I want to start mongo server. How can this be done?</p>