0

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.

user2089648
  • 1,356
  • 2
  • 17
  • 31
  • It looks like you were trying to do it with Vbscript which is what you need to do. You can't hide the console with any batch file commands. – Squashman Feb 23 '18 at 22:54

1 Answers1

0

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.

Gerhard
  • 22,678
  • 7
  • 27
  • 43
  • It works. When the code regarding WScript.Shell is run from a .vbs file instead of a batch file, it wont permanently open the command window. Actually you can just ditch the batch altogether and put all code into the vbScript that way. – user2089648 Feb 24 '18 at 07:26
  • @user2089648 Yes, hence why I said if you really want to use batch as well :) – Gerhard Feb 24 '18 at 07:27