gpt4 book ai didi

c++ - ShellExecute 中的 cmd 命令

转载 作者:搜寻专家 更新时间:2023-10-31 02:07:36 30 4
gpt4 key购买 nike

我正在尝试执行 netsh winsock reset catalog命令 command prompt来自 elevated(has admin privileage) c++ application .

HINSTANCE retVal = ShellExecute(NULL, "open", "cmd", "\c netsh winsock reset catalog > CUninstall.log", NULL, SW_NORMAL); 

它只是打开命令提示符,没有其他任何反应。我试过了

HINSTANCE retVal = ShellExecute(NULL, "runas", "cmd", "\c netsh winsock reset catalog > CUninstall.log", NULL, SW_NORMAL); 

HINSTANCE retVal = ShellExecute(NULL, "open", "cmd", " netsh winsock reset catalog > CUninstall.log", NULL, SW_NORMAL); 

最佳答案

切换字符导致了问题。它在切换字符从 \c 更改为 /c 时起作用。

表格

HINSTANCE retVal = ShellExecute(NULL, "open", "cmd", "\c netsh winsock reset catalog > CUninstall.log", NULL, SW_NORMAL);

HINSTANCE retVal = ShellExecute(NULL, "open", "cmd", "/c netsh winsock reset catalog > CUninstall.log", NULL, SW_NORMAL);

关于c++ - ShellExecute 中的 cmd 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48437377/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com