Search code examples
windowsbatch-filegodoc

Windows hidden godoc


I am having problems starting a godoc server hidden on my windows development machine. The idea is to have a batch that starts godoc and opens it in my browser. So far that works, but I cannot get rid of a console window holding the godoc output log. Is there some way to start it completely in the background?

My batch:

#start cmd /c "godoc -http=:8080 -goroot=D:\Programmieren\Go\pkg > nul"
#start godoc -http=:8080 -goroot=D:\Programmieren\Go\pkg > nul
#Set oShell = CreateObject("Wscript.Shell")
#oShell.Run "godoc -http=:8080 -goroot=D:\Programmieren\Go\pkg", 0, true
start godoc -http=:8080 -goroot=D:\Programmieren\Go\pkg
start "" http://localhost:8080/pkg/

The commented lines are things I have tried without success so far.


Solution

  • If you really want to run a cmd with the commands you must create a vbs file to call the file as a hidden console. So create a file called something like hidden.vbs and add:

    Set MyScript = CreateObject("WScript.Shell")
    MyScript.Run "C:\path to batch\yourbatch.cmd", 0, False
    

    Where C:\path to batch\yourbatch.cmd is the path to your batch file.

    Your batch file can then be as such:

    start "" godoc -http=:8080 -goroot=D:\Programmieren\Go\pkg && start "" http://localhost:8080/pkg/
    

    Then run the vbs file which will silently call the batch file.