Java调用命令行/启动notepad
Java启动命令行,其实非常简单,只要你知道Windows的命令行,然后直接用 Runtime.getRuntime().exec();就可以执行命令;eg: Process p1 = Runtime.getRuntime().exec("notepad d:\\1234.txt"); Process p2 = Runtime.getRuntime().exec("cmd /c notepad d:\\1234.txt"); Process p3 = Runtime.getRuntime().exec("cmd /c start notepad d:\\1234.txt"); 但是有些Windows命令行使用Runtime.getRuntime().exec(),是无法启动的,会抛出异常。 这里用直接总结了下,在附件的程序里,双击某一个命令就可以执行这个命令。 一下是常用的Windows命令行。 "打开记事本", "notepad" "启动计算器", "calc" "画图板", "mspaint" "远程桌面连接", "mstsc" "任务管理器", "taskmgr" "录音机", "sndrec32" "注册表编辑器", "regedt32" "剪贴板查看器", "Clipbrd" "CMD命令提示符", "cmd.exe" "音量控制程序", "Sndvol32" "检查DirectX信息", "dxdiag" "写字板", "write" "磁盘碎片整理程序", "dfrg.msc" "组策略", "gpedit.msc" "检查Windows版本", "winver" "打开windows管理体系结构(WMI}", "wmimgmt.msc" "windows更新程序", "wupdmgr" "windows脚本宿主设置", "wscript" "系统信息", "winmsd" "扫描仪和照相机向导", "wiaacmgr" "XP自带局域网聊天", "winchat" "显示内存使用情况", "mem.exe" "系统配置实用程序", "Msconfig.exe" "简易widnows media player", "mplayer2" "媒体播放机", "mplayer2" "放大镜实用程序", "magnify" "同步命令", "mobsync" "系统医生", "drwtsn32" "设备管理器", "devmgmt.msc" "磁盘管理实用程序", "diskmgmt.msc" "打开系统组件服务", "dcomcnfg" "打开DDE共享设置", "ddeshare" "DVD播放器", "dvdplay" "nger停止信使服务", "net stop messe" "enger开始信使服务", "net start mess" "网络管理的工具向导", "nslookup" "系统备份和还原", "ntbackup" "屏幕讲述人", "narrator" "移动存储管理器", "ntmsmgr.msc" "移动存储管理员操作请求", "ntmsoprq.msc" "命令检查接口(TC}", "netstat an" "创建一个公文包", "syncapp" "系统配置编辑器", "sysedit" "文件签名验证程序", "sigverif" "创建共享文件夹", "shrpubw" "本地安全策略", "secpol.msc" //"系统加密,一旦加密就不能解开,保护windows xp系统的双重密码", "syskey" "本地服务设置", "services.msc" "系统文件检查器", "sfc.exe" "windows文件保护", "sfc /scannow" //"关机命令60秒倒计时", "tsshutdn" //"xp简介(安装完成后出现的漫游xp程序}", "tourstart" "事件查看器", "eventvwr" "造字程序", "eudcedit" "打开资源管理器", "explorer" "对象包装程序", "packager" "计算机性能监测程序", "perfmon.msc" "程序管理器", "progman" "注册表", "regedit.exe" //"关机15秒", "rononce p " //"dll停止dll文件运行", "regsvr32/u *." //"pfldr.dll取消ZIP支持", "regsvr32/u zi" "Chkdsk磁盘检查", "chkdsk.exe" "证书管理实用程序", "certmgr.msc" "启动字符映射表", "charmap" "SQL SERVER 客户端网络实用程序", "cliconfg" "启动netmeeting", "conf" "计算机管理", "compmgmt.msc" "垃圾整理", "cleanmgr" "索引服务程序", "ciadv.msc" "打开屏幕键盘", "osk" "ODBC数据源管理器", "odbcad32" //"检查XP是否激活", "oobe/msoobe/a" "本机用户和组", "lusrmgr.msc" "注销命令", "logoff" "木马捆绑工具,系统自带", "iexpress" "IP地址侦测器", "Nslookup" "共享文件夹管理器", "fsmgmt.msc" "辅助工具管理器", "utilman" "组策略结果集", "rsop.msc" "打开控制台", "mmc"