Windows - exec call

import (
// “strings”

func main() {
cmd := exec.Command(“testbat”, “param1”, “param2”)
// cmd.Stdin = strings.NewReader(“some input”)
var out bytes.Buffer
var errout bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &errout
err := cmd.Run()
if err != nil {
fmt.Printf(“Error %q\n”, errout.String())
fmt.Printf(“Return %q\n”, out.String())

testbat is testbat.bat in my GO bin directory.


Error ""
2016/05/18 11:03:56 exit status 4294967295

The test .bat is not run, any idea what the error is ?
Or how to actually get this to work ?

I would suspect that your $GOPATH/bin is not in your PATH.
If that’s the case, when you run c:\Development\Go>workspace\bin\logincount.exe
you’re running logincount.exe which is in c:\Development\Go\workspace\bin\
but your working directory is c:\Development\Go> at that moment.
There logincount.exe will go looking for testbat and can’t find it and if it isn’t in your PATH, it won’t find it anywhere.

testbat.bat is in C:\Development\Go\bin, which is in my path

if on the command line (in C:\Development\Go) I run ‘testbat p1 p2’ it executes correctly, then I run ‘workspace\bin\logincount.exe’ I get the error.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.