How can i execute my sc
command through exec.Command
?
Code:
cmd := exec.Command("cmd.exe", "sc", "create", "Simpler", "binpath="+os.Getenv("APPDATA")+"\\Simpler\\cc.exe", "displayname=MY SERVICE");
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true};
out, _ := cmd.Output(); fmt.Println(string(out))
This i get in command prompt (open command prompt in current command prompt -_-):
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\WINDOWS\system32>cd c:\prog\logs
c:\prog\logs>go build test.go
c:\prog\logs>test.exe
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
c:\prog\logs>
c:\prog\logs>
Followed command cannot be executed. I do not get anything! Where is the problem?
Command been started if i execute sc.exe
in current command prompt but not started if i execute in new command prompt.
That is if i remove first argument "cmd.exe"
my program succesfully execute with excepted result. But how to execute in a new window?