ProcessStartInfo.Password 屬性

定義

重要

此 API 不符合 CLS 規範。

取得或設定安全字串,其中包含啟動處理序時要使用的使用者密碼。Gets or sets a secure string that contains the user password to use when starting the process.

public:
 property System::Security::SecureString ^ Password { System::Security::SecureString ^ get(); void set(System::Security::SecureString ^ value); };
[System.CLSCompliant(false)]
public System.Security.SecureString Password { get; set; }
member this.Password : System.Security.SecureString with get, set
Public Property Password As SecureString

屬性值

要在啟動處理序時使用的使用者密碼。The user password to use when starting the process.

屬性

備註

重要

如果提供 UserNamePassword,就必須設定 WorkingDirectory 屬性。The WorkingDirectory property must be set if UserName and Password are provided. 如果未設定屬性,則預設工作目錄為%Systemroot%\system32 中。If the property is not set, the default working directory is %SYSTEMROOT%\system32.

注意

ProcessStartInfo 物件中設定 DomainUserNamePassword 屬性,是使用使用者認證來啟動處理常式的建議做法。Setting the Domain, UserName, and the Password properties in a ProcessStartInfo object is the recommended practice for starting a process with user credentials.

SecureString 物件就像 String 物件,因為它具有文字值。A SecureString object is like a String object in that it has a text value. 不過,SecureString 物件的值會自動加密,在您的應用程式將其標示為唯讀之前,可以修改它,而且您的應用程式或 .NET Framework 垃圾收集行程都可以從電腦記憶體中刪除它。However, the value of a SecureString object is automatically encrypted, it can be modified until your application marks it as read-only, and it can be deleted from computer memory by either your application or the .NET Framework garbage collector.

如需安全字串的詳細資訊,以及如何取得密碼以設定此屬性的範例,請參閱 SecureString 類別。For more information about secure strings and an example of how to obtain a password to set this property, see the SecureString class.

注意

如果您提供 Password 屬性的值,則 UseShellExecute 屬性必須 false,或呼叫 Process.Start(ProcessStartInfo) 方法時,將會擲回 InvalidOperationExceptionIf you provide a value for the Password property, the UseShellExecute property must be false, or an InvalidOperationException will be thrown when the Process.Start(ProcessStartInfo) method is called.

適用於