0

I have written a program in C# which I would like to open automatically at startup. As such, I have added a value to the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run key:

Name: CustomTaskbar

Data: "C:\Users\test\Documents\CustomTaskbar\CustomTaskbar.exe"

Unfortunately, when I login, I am encountered with an error. Windows says 'CustomTaskbar has stopped working' and the details say this:

Files that help describe the problem:
  C:\Users\test\AppData\Local\Temp\WERECE7.tmp.WERInternalMetadata.xml
  C:\Users\test\AppData\Local\Temp\WERF655.tmp.appcompat.txt
  C:\Users\test\AppData\Local\Temp\WERF823.tmp.mdmp

I have no idea why this is happening, as it works just fine when I run it manually, either via Windows Explorer or cmd.

I have written the program in C#. Do I have to add anything to the code in order to make it compatible with the registry key?

I apologise in advance if this is a stupid question, with a simple answer, but I cannot find any fix online.

Thanks.

Mike Aguilar
  • 348
  • 2
  • 3
  • 14
Willumz
  • 36
  • 6
  • https://stackoverflow.com/a/3133249/17034 – Hans Passant May 02 '18 at 22:12
  • Oh my goodness... Thank you so much for pointing this out to me! Now that I can see the actual error I feel like an idiot. The program was being run from the system32 directory and so didn't have permission to create the files it was trying to. Thanks again. – Willumz May 02 '18 at 22:26
  • Please use what you've learned to complete the Q+A you started. – Hans Passant May 02 '18 at 22:36
  • Possible duplicate of [Win32 application doesn't run on startup](https://stackoverflow.com/questions/33808203/win32-application-doesnt-run-on-startup) – Raymond Chen May 03 '18 at 04:08

1 Answers1

1

Following the instructions provided by the link (https://stackoverflow.com/a/3133249/17034) kindly provided by Hans Passant, I was able to catch the exception. It turns out that while I had thought it was an issue with the way Windows was running it, it was in fact a stupid error on my behalf. I was referencing local paths like ”appfolder” and ”config.xml”. Windows was running the program from the system32 directory and, as the program did not have admin privileges, it was throwing an error, saying it couldn’t write to them.

I feel utterly ridiculous for having not noticed what would be happening before.

Willumz
  • 36
  • 6