Exec.Command trouble on Windows Server

Hi guys,

I want to execute shutdown command from golang on Windows Server 2008. The command work from cmd but from the code simply do nothing and exit with some error code 1. The program run with Administrator rights.

    _, err := exec.Command("C:\\Windows\\System32\\shutdown.exe","/s /f /d p:4:1").Output()
	if err != nil {

Otherwise, the same code on W7 work (without /f /d p:4:1 which is only for Windows Server)

	    _, err := exec.Command("C:\\Windows\\System32\\shutdown.exe","/s").Output()

Does anyone have any idea? Thanks.

Either ```
exec.Command(“C:\Windows\System32\shutdown.exe”,"/ss", “/f”, “/d”, “p:4:1”).Output()


exec.Command(“cmd.exe”, “C:\Windows\System32\shutdown.exe /ss /ff /d p:4:1”).Output()


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