Installing Dgraph "Globally" on Windows

I will show you a simple way to run the Dgraph binary made for Windows. Wherever your terminal (cmd, PowerShell or any other - except WSL) is. I mean “globally” as unix systems does.

It is a simple script in “Batch” (.bat)

First, you need to download the Windows binary from our release page. Releases · dgraph-io/dgraph · GitHub

Choose the “dgraph-windows-amd64.tar.gz” file of any version you prefer.

Choose a path (folder) that you will unzip GZ into (can be at downloads folder). If you need to, google a gz unzip that suits you best.

You will then use an editor of your choice to create a .bat - Copy the code below and paste into the editor and save it to the same path that you unzipped Dgraph.

@ECHO OFF
SET WORKPATH=C:\Users\micheldiz\Downloads\
if not exist "%HOMEDRIVE%\dgraph-io" mkdir "%HOMEDRIVE%\dgraph-io"
move %WORKPATH%\dgraph.exe "%HOMEDRIVE%\dgraph-io"
move %WORKPATH%\dgraph-ratel.exe "%HOMEDRIVE%\dgraph-io"
move %WORKPATH%\badger.exe "%HOMEDRIVE%\dgraph-io"
SETX PATH /M "%HOMEDRIVE%\dgraph-io;%PATH%"
ECHO "%HOMEDRIVE%"
ECHO %WORKPATH%"
PAUSE

You have to edit the variable WORKPATH= to the path you have unzipped Dgraph.

Run the {name you gave}.bat as administrator (because the bat will place environment variables for all users. That way, you need to be an administrator. If you are not, you can remove the /M flag - e.g.: SETX PATH "%HOMEDRIVE%\dgraph-io;%PATH%")

Now test it, restart your Windows terminal. And from any path run “dgraph-ratel” for example.

That’s it.
Cheers!

1 Like