2015-09-04 96 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%'