Willumz
Willumz

Reputation: 36

Program not running from 'Run' registry key

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.

Upvotes: 0

Views: 3161

Answers (1)

Willumz
Willumz

Reputation: 36

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.

Upvotes: 1

Related Questions