Solved

Java - start prog on pc start and other funtions

Posted on 2004-08-06
3
293 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

713 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