Startup folder in .NET

  • Thread starter Thread starter bob laughland
  • Start date Start date
B

bob laughland

Hi All,

Within our application is some configuration which allows the user to
add a link into the startup folder. That of course will mean our
application would then start automatically when windows starts.

We are using .NET 3.5 C#. So I am using this C# code to get the
startup folder path,

Environment.GetFolderPath(Environment.SpecialFolder.Startup)

That works on my local development machines (windows 2008 server and
vista). But it does not work on our build server, what I mean is it
actually returns an empty string on our build server.

It used to work on our old build server (windows 2003) but when I
rebuilt our build server using windows 2008 it didn't work.

Any ideas? Is it the case that when the startup folder has not been
used before something within the OS has not been initialised?
 
This kind of thing depends on the account you're running with (I don't think
SYSTEM has a profile) and whether you're impersonating (which by default
does not load registry hive data for that user). If it's an account which
has never interactively logged on then maybe those folders have never been
set up. It will also depend on whether anyone actually logs on or not. The
Startup folder is not run when Windows starts (for which you need a service)
but when logon occurs.
 
Back
Top