Cmd shell to call the .js file to load data

Hello, in command shell, the only way to get to the mongo details is by changing the directory to bin and call mongo as follows:
cd program files
cd mongodb
cd server
cd 4.0
cd bin
mongo "mongodb…–username xxx --password yyy …

then I can show dbs and it will list admin and local
Question:
How do I run the .js which I have placed into this folder:
c:\mongodb\university\m001\loadmoviedetailsdataset

?
Thank you

An application does not know where your files reside. It could know but it would take a ridiculous long time ton find out where the file Bla.js is. And if more than one, how to differ.

Windows does not know where your applications reside. It could know but it would take a ridiculous long time ton find out where the file mongo.exe is. And if more than one, how to differ.

The solution for Windows to find the .exe is:

  1. You either set your PATH in Windows so that it can find the application --OR–
  2. Enter the full path name of the .exe file --OR–
  3. Like you did cd to the appropriate directory

The solution for the application to find the config file is:

A. Enter the full path name of the config file --OR–
B. cd to the directory that contains the config file

If you chose 1. or 2. you have to do A. unless you did B.
If you chose 3. you have to do A.

Hi, thanks for your reply.
for some reasons my windows path can not be set. Any way, I have to always browse to the bin directory and call mongo in there , i.e. mongo --nodb
the mongo.exe resides in
c:\program files\ mongodb\server\4.0\bin\mongo.exe

The .js resides in c:\mongodb\university\m001\loadmoviedetailsdataset

I am still unclear how to call the .js file as explained in course video.
Can you give more guidance on the cmd code to get to .js please?

Thank you

When you are in c:\program files\ mongodb\server\4.0\bin\ you may try

mongo c:\mongodb\university\m001\loadmoviedetailsdataset\(filename).js

If you are in c:\mongodb\university\m001\loadmoviedetailsdataset you may try

“c:\program files\ mongodb\server\4.0\bin\mongo.exe” (filename).js

It will simplify your life immensely if you can set your path. I am not Windows, so I cannot really help you with that.

Thanks for the explanation…
I did as you suggested but get he message below and not what is inside the .js
Any suggestions pls?

C:\MongoDB\University\M001\loadMovieDetailsDataset>“C:\Program Files\MongoDB\Server\4.0\bin\mongo.exe” loadMovieDetailsDataset.js
MongoDB shell version v4.0.6
connecting to: mongodb://ipaddress here…:27017/?gssapiServiceName=mongodb
Implicit session: session { “id” : somenumbershere…") }
MongoDB server version: 4.0.6

Thank you

I am not familiar enough with Windows and the content of M001 to help you further.

However I will try any way?

Can you provide the output of the following command.

cd C:\MongoDB\University\M001\loadMovieDetailsDataset
dir

Hi, thanks for your time:
output

21/03/2019 20:29 .
21/03/2019 20:29 …
21/03/2019 20:29 1,381,666 loadMovieDetailsDataset.js
1 File(s) 1,381,666 bytes
2 Dir(s) 166,871,216,128 bytes free