Skip to content

Instantly share code, notes, and snippets.

@frapontillo
Created December 4, 2014 22:28
Show Gist options
  • Save frapontillo/0b76526772560f2371d9 to your computer and use it in GitHub Desktop.
Save frapontillo/0b76526772560f2371d9 to your computer and use it in GitHub Desktop.
MongoDB Batches for Windows
mkdir %~dp0data\db
mkdir %~dp0log
echo logpath=%~dp0log\mongo.log >> "%~dp0mongod.cfg"
echo dbpath=C:\mongodb\data\db >> "%~dp0mongod.cfg"
sc.exe create MongoDB binPath= "\"%~dp0bin\mongod.exe\" --service --config=\"%~dp0mongod.cfg\"" DisplayName= "MongoDB" start= "auto"
net start MongoDB
pause
net stop MongoDB
sc.exe delete MongoDB
rmdir %~dp0data /S /Q
rmdir %~dp0log /S /Q
rm %~dp0mongod.cfg
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment