ProcessStartInfo.UserName 属性

定义

获取或设置在启动进程时使用的用户名。Gets or sets the user name to use when starting the process. 如果使用 UPN 格式,user@DNS_domain_name,则 Domain 属性必须为 nullIf you use the UPN format, user@DNS_domain_name, the Domain property must be null.

public:
 property System::String ^ UserName { System::String ^ get(); void set(System::String ^ value); };
public string UserName { get; set; }
member this.UserName : string with get, set
Public Property UserName As String

属性值

String

启动进程时使用的用户名。The user name to use when starting the process. 如果使用 UPN 格式,user@DNS_domain_name,则 Domain 属性必须为 nullIf you use the UPN format, user@DNS_domain_name, the Domain property must be null.

注解

重要

WorkingDirectory如果 UserName 提供了和,则必须设置属性 PasswordThe WorkingDirectory property must be set if UserName and Password are provided. 如果未设置该属性,则默认工作目录为%Systemroot%\system32If the property is not set, the default working directory is %SYSTEMROOT%\system32.

如果 UserName 属性不为 null 或空字符串,则 UseShellExecute 属性必须为 false ,否则在 InvalidOperationException 调用方法时将引发 Process.Start(ProcessStartInfo)If the UserName property is not null or an empty string, the UseShellExecute property must be false, or an InvalidOperationException will be thrown when the Process.Start(ProcessStartInfo) method is called.

适用于