Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Java - start prog on pc start and other funtions

Posted on 2004-08-06
3
Medium Priority
?
315 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 200 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

885 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