Programmatically Restart Computer/Application

  • Thread starter Thread starter John Spiegel
  • Start date Start date
J

John Spiegel

Hi all,

Is there a way to programmatically restart Windows (2000, specifically),
login automatically then start an application? I've been running across
some Windows Shell options (which further examples would be appreciated) but
would particularly like to find a .NET-specific example.

TIA,

John
 
John,

To restart the computer, you can use the ExitWindowsEx API function,
which you can call through the P/Invoke layer.

To automatically log in and start an application, well, that's not such
a good idea. You might want to consider just running a service.

Hope this helps.
 
Hi Nicholas,

Thanks for the info!

The program I'm trying to kick off is not .NET-based and cautions against
running as a service. I do agree that it's generally poor form to
automatically do what I'm looking to, um, automatically do. In this case,
we have a single machine that suffers from memory leaks when it runs this
other app and we'd like to be able to let it reboot and start back up w/o
intervention--especially to take advantage of the overnight processing time.
It seems to me (though I'm pretty new to .NET and OS APIs) that not running
as a service would lead me back to setting the app to run in the start up
for the user and log them back in.

Thanks,

John

Nicholas Paldino said:
John,

To restart the computer, you can use the ExitWindowsEx API function,
which you can call through the P/Invoke layer.

To automatically log in and start an application, well, that's not such
a good idea. You might want to consider just running a service.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

John Spiegel said:
Hi all,

Is there a way to programmatically restart Windows (2000, specifically),
login automatically then start an application? I've been running across
some Windows Shell options (which further examples would be appreciated) but
would particularly like to find a .NET-specific example.

TIA,

John
 
Back
Top