2015-09-04 94 views
0

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

我无法找到一种方法来实现这个任务。请帮忙。

回答

0

尝试:

Run, PowerShell "new-item -path c:\ -name logfiles -itemtype" 

似乎为我工作。

编辑根据新提供的信息:

命令发现@http://exchangeserverpro.com/install-exchange-2013-pre-requisites-windows-server-2012/

尝试:

Run, PowerShell "Install-WindowsFeature AS-HTTP-Activation 
       , Desktop-Experience 
       , NET-Framework-45-Features 
       , RPC-over-HTTP-proxy 
       , RSAT-Clustering 
       , Web-Mgmt-Console 
       , WAS-Process-Model 
       , Web-Asp-Net45 
       , Web-Basic-Auth 
       , Web-Client-Auth 
       , Web-Digest-Auth 
       , Web-Dir-Browsing 
       , Web-Dyn-Compression 
       , Web-Http-Errors 
       , Web-Http-Logging 
       , Web-Http-Redirect 
       , Web-Http-Tracing 
       , Web-ISAPI-Ext 
       , Web-ISAPI-Filter 
       , Web-Lgcy-Mgmt-Console 
       , Web-Metabase 
       , Web-Mgmt-Console 
       , Web-Mgmt-Service 
       , Web-Net-Ext45 
       , Web-Request-Monitor 
       , Web-Server 
       , Web-Stat-Compression 
       , Web-Static-Content 
       , Web-Windows-Auth 
       , Web-WMI 
       , Windows-Identity-Foundation" 
+0

你提供的那个也适用于我。但是,当我使用'Add-Windowsfeature'命令而不是该示例中的命令时,出现一个错误,指出VARIABLE NAME TOO LONG太长。任何建议请。 – samisda1

+0

我编辑了包含Add-Windowsfeature代码的代码,但是如果它正在工作还没有报告回来? – errorseven

+0

运行后出现同样的错误。你能想到的其他方式吗?非常感谢。 – samisda1

0

PowerShell是没有必要解决这个特定的问题。

AutoHotkey的具有内置功能,创建目录:FileCreateDir

例如:

FileCreateDir, C:\logfiles 
+0

@Chad ..我提供的命令只是一个例子。其实我想从下面的文章中运行'Add-Windowsfeature'命令:http://exchangeserverpro.com/install-exchange-2013-pre-requisites-windows-server-2012/我无法运行它,因为一个说VARIABLE NAME太长的错误。请建议。 – samisda1

1

如果你想运行从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%'