Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Screensaver does not find config file

I've written a screen saver in C# and Windows Forms. For testing I've been lazy and just used the config file for all my settings (no settings dialog yet), but the program seems to be unable to find or read the config file when windows runs the screensaver.

It works when I use the preview button or run it manually in any way, its only when it hits the screensaver timeout that it is unable to find the config file.

Having it log AppDomain.CurrentDomain.SetupInformation.ConfigurationFile It returns the short name: C:\Windows\System32\MYSCRE~1.config Where it should be C:\Windows\System32\MyScreenSaverName.scr.Config

So I'm guessing the problem is that it can't find the config file with the short name path.

Not sure if its due to the system account which Windows 7 runs screen savers under, or something else about how it gets run. Any information would be helpful, thanks.

Edit: Trying to find any differences:

  1. Only difference I can find is that Environment.CommandLine returns C:\Windows\system32\MYSCRE~1.SCR /s when Windows runs the screen saver, but has the normal path when I run it
  2. Everything under Process.GetCurrentProcess().StartInfo is the same
  3. WindowsIdentity.GetCurrent().Name is my account name

Looking at other questions, it seems that User32 is what starts the screensavers, so I'm figuring it has to be something about how that starts up the scr process.

Work Around: Renaming my .scr file to have 8 characters or less allows it to work correctly. So that works for now, would still love to know why this problem exists.

like image 487
Thymine Avatar asked Oct 18 '11 18:10

Thymine


1 Answers

edit: ouch... I noticed too late that it's a 1 year old question.... well maybe someone can find this usefull anyway.


Are you sure the filesystem isn't fat/fat32 instead of ntfs?

Maybe it's a Win7 upgraded from an old fat/fat32 formatted system? (and so fs were not upgraded)?

Maybe I'm wrong, it's just my guess to see short names in place. I recently worked on a screensaver project in c# and I encountered no problems at all... I don't see short names since ages to be honest...

You should see the fs type from Disk management. Doing some research i also got this, check if FUTIL.EXE can help, there is a curious "disable8dot3" option right there:

http://commandwindows.com/fsutil.htm

like image 100
Squiffy Avatar answered Sep 20 '22 07:09

Squiffy