开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜