question

MiPakTeh-6272 avatar image
0 Votes"
MiPakTeh-6272 asked DanielZhang-MSFT edited

Run program c# at startup windows

95708-ask.txt


dotnet-csharp
ask.txt (4.8 KiB)
· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @MiPakTeh-6272,
>>My problem is, it can start a Watcher.exe but at the windows Load become error "The program Stop Working".
First, I made a test with your code and didn't encounter the error you said.
And what is "windows Load"? Please explain in detail and provide more information to reproduce the situation.
Best Regards,
Daniel Zhang

0 Votes 0 ·

96218-capture.png



sorry my explanation not good. "Windows Load" is startup windows





0 Votes 0 ·
capture.png (120.4 KiB)

Hi @MiPakTeh-6272 ,
About Windows is checking for a solution to the problem error, I suggest you try to follow the steps below to disable error reporting in Windows 10:
1.Click the Start menu, type services and press Enter.
2Find Windows Error Reporting Service and then right-click on that entry from the list.
3.Select Properties.
4.Next to Startup type, select Disabled from the drop down.
5.Click OK or Apply to save the settings.
Best Regards,
Daniel Zhang

0 Votes 0 ·
Show more comments

Thank you very very much.

0 Votes 0 ·

Hi @MiPakTeh-6272,
I am very happy to help you solve the problem, I have turned my comment into an answer.
And I am glad to help if you have any other questions.
Best Regards,
Daniel Zhang

0 Votes 0 ·
DanielZhang-MSFT avatar image
0 Votes"
DanielZhang-MSFT answered DanielZhang-MSFT edited

Hi @MiPakTeh-6272 ,
What version of your Windows system?
And you can try to run Services as an administrator
1. Click on Start.
2. In the start Search box type “Services”.
3. Right Click on run as administrator.
97003-517.png
Best Regards,
Daniel Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



517.png (65.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

cheong00 avatar image
0 Votes"
cheong00 answered MiPakTeh-6272 commented

Check and see if sOri actually exists.

Also, if sOri points to network mounted folders, the network path may not be accessible yet.

It will be useful to debug if you can wrap your Form1_Load() content in try...catch... block and show the exception message with MessageBox.Show().

You may find corresponding error event in Event Viewer -> Application too since the error is not handled.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

cheong00 can you show an example ;

It will be useful to debug if you can wrap your Form1_Load() content in try...catch... block and show the exception message with MessageBox.Show().

0 Votes 0 ·
             private void Form1_Load(object sender, EventArgs e)
             {
                 try
                 {
                     watcher.NotifyFilter = NotifyFilters.Attributes
                     | NotifyFilters.CreationTime
                     | NotifyFilters.DirectoryName
                     | NotifyFilters.FileName
                     | NotifyFilters.LastAccess
                     | NotifyFilters.LastWrite
                     | NotifyFilters.Security
                     | NotifyFilters.Size;
            
                     string sOri = @"C:\";
                     watcher.Path = sOri;
                     watcher.Created += OnCreated;
                     watcher.IncludeSubdirectories = true;
                     watcher.EnableRaisingEvents = true;
                 }
                 catch (Exception ex)
                 {
                    MessageBox.Show(ex.ToString());
                 }
             }
0 Votes 0 ·

96638-capture1.png



When follow you advice , the error message like above.
Help me, I don't how to do.

0 Votes 0 ·
capture1.png (108.2 KiB)
cheong00 avatar image
0 Votes"
cheong00 answered MiPakTeh-6272 commented

You don't have right to listen to folders that you don't have access to.

Try limit the access to somewhere that user can write instead.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

both of answer...good

0 Votes 0 ·