c++ - 从 C++ 调用 powershell cmdlet

标签 c++ powershell visual-c++

我在 C++ 项目中使用 Visual Studio 2010。我想从我的 C++ 代码中执行 "Set-SmbServerConfiguration –EncryptData $true" cmdlet。

我尝试使用 system() 但它不起作用。可能是在执行如下命令后卡在 confirm 选项:

Confirm
Are you sure you want to perform this action?
Performing operation 'Modify' on Target 'SMB Server Configuration'.
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):

有没有什么方法可以使用 Windows 中的 C++ 代码的默认确认值(“Y”)来做到这一点?

最佳答案

尝试将 confirm:$false 添加到 powershell

关于c++ - 从 C++ 调用 powershell cmdlet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46360419/

相关文章:

c++ - "(void) new"在 C++ 中是什么意思?

powershell - 在 Win7 上的 powershell 命令行中使用私钥在 TrustedRootCA 中安装 .pfx 证书

powershell - 通过 DSC 将 Web 前端、服务后端和 SQL Server 部署到虚拟机?

c++ - 与普通互斥锁相比,唯一锁如何工作?

c++ - 将 .lib 项目转换为 exe 一个

c++ - 如何检索添加到由其父类(super class)对象组成的集合中的派生对象?

c++ - 使用带闭包的 lambda 回调

Powershell 删除引号参数

windows - 无法在 Windows 64 位上使用 Visual C++ Express 链接到 fftw 库

c++ - 混合 C/C++ 代码产生 "undefined symbol"与共享库