首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >通过AutoHotKey脚本运行powershell命令

通过AutoHotKey脚本运行powershell命令
EN

Stack Overflow用户
提问于 2015-09-04 19:31:08
回答 3查看 9.9K关注 0票数 4

我希望能够通过AutoHotKey脚本运行以下PowerShell命令:

代码语言:javascript
运行
复制
new-item -path c:\ -name logfiles -itemtype directory

我找不到完成这项任务的方法。请帮帮忙。

EN

Stack Overflow用户

发布于 2016-03-07 21:04:30

如果你想从ahk运行一个PowerShell脚本,它包含几行代码,并且你不想使用外部文件,这是一个如何操作的例子:

AutoHotkey代码:

代码语言:javascript
运行
复制
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%'   
票数 8
EN
查看全部 3 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32397032

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档