从C ++调用powershell cmdlet

时间:2017-09-22 08:41:37

标签: c++ powershell visual-c++

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

我尝试使用system()但它不起作用。执行命令后可能会卡在确认选项上,如下所示:

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”)来做这个?

2 个答案:

答案 0 :(得分:1)

尝试将确认:$ false添加到poweshell

答案 1 :(得分:0)

使用管理员权限运行程序解决了该问题,使用以下命令:g = (np.arange(9) - 4).reshape((3, 3)) g Out[215]: array([[-4, -3, -2], [-1, 0, 1], [ 2, 3, 4]]) col_norm = g/np.linalg.norm(g, axis=0, keepdims=True) col_norm Out[217]: array([[-0.87287156, -0.70710678, -0.43643578], [-0.21821789, 0. , 0.21821789], [ 0.43643578, 0.70710678, 0.87287156]]) row_norm = g/np.linalg.norm(g, axis=1, keepdims=True) row_norm Out[219]: array([[-0.74278135, -0.55708601, -0.37139068], [-0.70710678, 0. , 0.70710678], [ 0.37139068, 0.55708601, 0.74278135]])