Install MongoDB as Windows Service

mkdir c:\data\db
mkdir c:\data\log

create a file at C:\mongodb\mongod.cfg

systemLog:
    destination: file
    path: c:\data\log\mongod.log
storage:
    dbPath: c:\data\db

Install the MongoDB service

"C:\mongodb\bin\mongod.exe" --config "C:\mongodb\mongod.cfg" --install

Start the MongoDB service

net start MongoDB

Stop or remove the MongoDB service as needed

net stop MongoDB
"C:\mongodb\bin\mongod.exe" --remove

References :
https://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/