我希望能够通过AutoHotKey脚本运行以下PowerShell命令:
new-item -path c:\ -name logfiles -itemtype directory
我找不到完成这项任务的方法。请帮帮忙。
发布于 2016-03-07 21:04:30
如果你想从ahk运行一个PowerShell脚本,它包含几行代码,并且你不想使用外部文件,这是一个如何操作的例子:
AutoHotkey代码:
psScript =
(
param($param1, $param2)
new-item -path $param1 -name logfiles -itemtype directory
new-item -path $param2 -name logfiles -itemtype directory
remove-item -path 'c:\temp'
# etc, write any code, use this quotes for strings: '
# if you need ", then write: \":
$import = '[DllImport(\"ntdll.dll\")] public static extern int RtlAdjustPrivilege(ulong a, bool b, bool c, ref bool d);'
)
param1 = C:\temp
param2 = D:\temp
RunWait PowerShell.exe -Command &{%psScript%} '%param1%' '%param2%',, hide
; use this call if you want to see powershell output
Run PowerShell.exe -NoExit -Command &{%psScript%} '%param1%' '%param2%'
https://stackoverflow.com/questions/32397032
复制相似问题