如何在Windows上从Golang执行netsh命令

时间:2017-02-13 12:56:20

标签: go netsh

如何执行

  

netsh

来自Golang的

命令需要"以管理员身份运行"?

err1 := exec.Command("netsh", "interface ipv6 set privacy state=disable").Run()
fmt.Printf("Exec1 err: %+v\n", err1)

1 个答案:

答案 0 :(得分:1)

尝试std::wstringstream wss; wss << std::wstring(L"\"") << CPathUtil::get_exe_fullpath() << std::wstring(L"\"") << L" /q /a " << std::wstring(L"\"") + cp.c_str() + std::wstring(L"\""); const auto command = wss.str(); const auto result = _wsystem(command.c_str());