RunAs

Specifies a set of user credentials to use for all subsequent Run and RunWait functions.

RunAs User, Password, Domain

パラメータ

User

型:文字列

このパラメータと他のパラメータをすべて省略した場合、RunAs機能はオフになり、RunRunWaitはデフォルトの動作に戻ります。Otherwise, specify the username under which new processes will be created.

Password

型:文字列

If blank or omitted, it defaults to a blank password. Otherwise, specify the User's password. Note that passing blank passwords is not allowed by default, according to the OS policy "Accounts: Limit local account use of blank passwords to console logon only".

Domain

型:文字列

If blank or omitted, a local account will be used. Otherwise, specify User's domain. これでうまくいかない場合は、@YourComputerNameを使用してみてください。

備考

If the script is running with restricted privileges due to User Account Control (UAC), any programs it launches will typically also be restricted, even if RunAs is used. To elevate a process, use Run *RunAs instead.

This function does nothing other than notify AutoHotkey to use (or not use) alternate user credentials for all subsequent Run and RunWait functions. この機能では、資格証明書は検証されません。

If an invalid User, Password, and/or Domain is specified, Run and RunWait will display an error message explaining the problem (unless this error is caught by a Try/Catch statement).

RunAs機能が有効な間は、RunおよびRunWaitは、ドキュメント、URL、システム動詞を起動することができなくなります。つまり、起動するファイルは実行可能なファイルである必要があります。

この機能を使用するには、「セカンダリログオン」サービスを手動または自動に設定する必要があります(手動に設定した場合は、要求に応じてOSが自動的に起動する必要があります)。

Run, RunWait

レジストリエディタを管理者として開く。

RunAs "Administrator", "MyPassword"
Run "RegEdit.exe"
RunAs  ; Reset to normal behavior.