gpt4 book ai didi

powershell - 将PowerShell命令转换为脚本

转载 作者:行者123 更新时间:2023-12-03 01:03:39 24 4
gpt4 key购买 nike

从批处理文件(或命令提示符)运行时,以下PowerShell命令将关闭屏幕。我希望将其作为PowerShell脚本运行。

Turn Off Screen - TechNet Script Center

powershell (Add-Type '[DllImport(\"user32.dll\")]^public static
extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);'
-Name a
-Pas)::SendMessage(-1,0x0112,0xF170,2)



我查看了 Add-Type - Microsoft Docs,但无法正确获取参数。

与此等效的PowerShell脚本是什么?

最佳答案

Add-Type -MemberDefinition @"
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);
"@ -Name "Win32SendMessage" -Namespace "Win32Functions"

[Win32Functions.Win32SendMessage]::SendMessage(-1,0x0112,0xF170,2)

关于powershell - 将PowerShell命令转换为脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52302191/

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