开发者

Difference starting program from registry to starting from startup folder [duplicate]

开发者 https://www.devze.com 2023-03-13 11:28 出处:网络
This question already has an answer here: Why does impersonating a process return "The directory name is invalid"?
This question already has an answer here: Why does impersonating a process return "The directory name is invalid"? (1 answer) Closed 2 years ago.

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")
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号