代码里面执行bat
public static void executeBat(String path) {
try {
File file = new File(path);
if (file.exists()) {
String parentpath = file.getParent();
parentpath = parentpath.replaceAll("\\\\", "/");
String fname = file.getName();
Runtime rntime = java.lang.Runtime.getRuntime();
if (Common.WINDOWS) {
if (!fname.endsWith(".bat")) {
fname = fname.substring(0, fname.lastIndexOf("."))
+ ".bat";
}
path = parentpath + "/" + fname;
Process process = rntime.exec("cmd /c start " + path);
}
}
} catch (Exception e) {
}
代码里面执行bat的更多相关文章
- 在c++代码中执行bat文件 【转】
我想在c++代码中执行磁盘上的一个bat文件. 这个bat文件的完整路径是:E:\\7z\\my7z.bat. 方法一: system("E:\\7z\\my7z.bat"); s ...
- java执行bat代码
java执行bat代码.txt public static void runbat(String path,String filename) { String cmd = "cmd /c s ...
- Windows Server 2008中使用计划任务定时执行BAT bat进行PHP脚本的执行
Windows Server 2008中使用计划任务定时执行BAT bat进行PHP脚本的执行 2016年01月03日 17:36:00 持之以恒 阅读数:5520 标签: windows定时任务.b ...
- ASP.NET 执行bat文件。
参考代码: http://blog.csdn.net/youngivan/article/details/7722384 在VS开发环境上是 网站应用程序能够正常执行bat,在winServer服务器 ...
- Js使用WScript.Shell对象执行.bat文件和cmd命令
Js使用WScript.Shell对象执行.bat文件和cmd命令 http://www.jb51.net/article/58669.htm WScript.Shell(Windows Script ...
- 在window下, Java调用执行bat脚本
参考博客: https://www.cnblogs.com/jing1617/p/6430141.html 最近一段时间用到了Java去执行window下的bat脚本, 这里简单记录一下: 我这里是先 ...
- windows开机自动执行bat脚本
一.以windows下备份sql数据库为例,开机自动执行.bat脚本 1.新建dump.bat文件,文件中的代码如下: set YYYYmmdd=%date:~0,4%%date:~5,2%%date ...
- windows开机执行bat
一.以windows下备份sql数据库为例,开机自动执行.bat脚本 1.新建dump.bat文件,文件中的代码如下: set YYYYmmdd=%date ...
- bat代码中判断 bat是否是以管理员权限运行,以及自动以管理员权限运行CMD BAT
· bat 代码中判断bat是否是以管理员权限运行,以及自动以管理员权限运行CMD BAT 一.判断bat是否是以管理员权限运行 @echo off net.exe session >NUL & ...
随机推荐
- poj1992 数论
//Accepted 168 KB 969 ms //n!中含有质因数p的个数为t=n/p+n/p^2+n/p^3+... #include <cstdio> #include <c ...
- mp3文件 ID3v2 帧标识的含义
mp3文件 ID3v2 帧标识的含义 Declared ID3v2 frames The following frames are declared in this draft. 4.20 AENC ...
- C语言数据类型在IA32中的大小
这个主要是一些常识问题,以及在使用AT&T语法汇编时会使用的编码后缀: C声明 Intel数据类型 汇编后缀 大小(byte) char 字节 b 1 short 字 w 2 int ...
- 【LeetCode OJ】Best Time to Buy and Sell Stock III
Problem Link: http://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/ Linear Time Solut ...
- iOS 静态库和动态库的区别&静态库的生成
linux中静态库和动态库的区别 一.不同 库从本质上来说是一种可执行代码的二进制格式,可以被载入内存中执行.库分静态库和动态库两种. 1. 静态函数库 这类库的名字一般是libxxx.a:利用静态函 ...
- 学习笔记:iPhone终极指南、手机端、浏览器各种规范
手机图解参考:http://www.paintcodeapp.com/news/iphone-6-screens-demystified 手机图标尺寸参考:https://developer.appl ...
- css 时钟
(转自:http://www.cnblogs.com/Wenwang/archive/2011/09/21/2184102.html) <!DOCTYPE html> <html l ...
- Ubuntu安装Sun JDK及如何设置默认java JDK
假设系统为Ubuntu 10.10 64位. 先来看看当前的系统默认的java版本,及提供商.通过命令java -version kemix@kemix-VB10-64:~$ jav ...
- VS2010单元测试
编号:1016时间:2016年5月26日09:35:27功能:VS2010单元测试URL :http://blog.csdn.net/tjvictor/article/details/6175362
- ng-init