Difference starting program from registry to starting from startup folder [duplicate]
We have a simple application with a button that opens the event viewer using process start.
public static void OpenWindowsEventViewer(
string computerDnsName,
string userName,
SecureString password,
string domain)
{
Process.Start("eventvwr.exe", computerDnsName, userName, password, domain);
}
When starting our tool from the registry using HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\R开发者_Python百科un it starts normally but fails to start the "eventvwr.exe" process with the error: 'The directory name is invalid'.
Starting our tool using the autostart folder (Start->Programs->Autostart) it works perfectly.
What is the difference between these two ways and I there anything I can do to make it work starting from the registry?
Edit: Removing the SecureString makes it work...
Use the complete path to eventvwr.exe
:
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "eventvwr.exe")
精彩评论