Solved

Java - start prog on pc start and other funtions

Posted on 2004-08-06
3
259 Views
Last Modified: 2012-05-05
Hi,

I am writing a small utility program for myself. I am wanting the program to have the following functionality:

1. Program should automatically run when the OS runs.
2. And i want to be able to log off, restart and shutdown the system when I want (i will use buttons for this).

The OS i am using for myself is MS Windows XP, I am aware that I could use the Win32 API (by using JNI), but I have hardly none Win32 API and the JNI experience. Is there a java class solution for this?

Thanks!
0
Comment
Question by:Ravi Singh
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 50 total points
ID: 11733964
1) add a registry entry to:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run

a String key like:

key: "myapplication" value: "path to your script to start the application"

2)  Try:

// shutdown Windows
Runtime.getRuntime().exec( "cmd /C \"rundll32.exe shell32.dll,SHExitWindowsEx\"" ) ;

// reboot Windows
Runtime.getRuntime().exec( "cmd /C \"rundll32.exe shell32.dll,SHExitWindowsEx 2\"" ) ;

// power down
Runtime.getRuntime().exec( "cmd /C \"rundll32.exe shell32.dll,SHExitWindowsEx 3\"" ) ;

That may work :-)
0
 
LVL 18

Author Comment

by:Ravi Singh
ID: 11734011
Thanks Tim :)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11734030
Did it work?

Cool :-)

Good luck!!

Tim
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now