开机运行:String regKey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"
String myAppName = "DaKa"
try {
Runtime.getRuntime().exec("reg " + (isStart ? "add " : "delete ") + regKey + " "
+ myAppName + (isStart ? " /t reg_sz /d " + dirpath : " /f"))
dirpath是你当前文件的绝对路径(包括文件名)
关机:Runtime.getRuntime().exec("shutdown -s -f -t 10")
我倒有个方法,就是调用关机程序try{
Runtime.getRuntime().exec("cmd /c Shutdown.exe")
}catch(Exception ex){}
哈哈,偶也是菜鸟,都是自己想的笨方法,不过好像是能关机哦,自己没试过
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)