java中运行bat文件怎么才能不产生dos窗口,不带闪的 20
java中运行一个bat文件如下:@echooffC:/temp/ffmpeg.exe-irtsp://218.204.223.237:554/live/1/66251F...
java中运行一个bat文件如下:
@echo off
C:/temp/ffmpeg.exe -i rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp -qscale 0 -t 00:00:30 -y C:/temp/%1 >C:/temp/log.txt 2>&1
exit
java中调用:
String strcmd = "cmd /c start C:\\temp\\ffmpeg.bat " + savePath;
Runtime.getRuntime().exec(strcmd);
怎样才能在运行中不产生Dos窗口 展开
@echo off
C:/temp/ffmpeg.exe -i rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp -qscale 0 -t 00:00:30 -y C:/temp/%1 >C:/temp/log.txt 2>&1
exit
java中调用:
String strcmd = "cmd /c start C:\\temp\\ffmpeg.bat " + savePath;
Runtime.getRuntime().exec(strcmd);
怎样才能在运行中不产生Dos窗口 展开
展开全部
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.SequenceInputStream;
public class Processing {
public static void main(String[] args) throws InterruptedException {
try {
Process process = Runtime.getRuntime().exec("cmd");
SequenceInputStream sis = new SequenceInputStream(process.getInputStream(), process.getErrorStream());
InputStreamReader isr = new InputStreamReader(sis, "GBK");
BufferedReader br = new BufferedReader(isr);
// next command
OutputStreamWriter osw = new OutputStreamWriter(process.getOutputStream());
BufferedWriter bw = new BufferedWriter(osw);
bw.write("cd /d d:/我的文档/桌面");
bw.newLine();
bw.write("ffmpeg -help");
bw.newLine();
bw.flush();
bw.close();
osw.close();
// read
String line = null;
while (null != (line = br.readLine())) {
System.out.println(line);
}
process.destroy();
br.close();
isr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
展开全部
解决不弹框只需要“start”后面加一个参数“/b”就行:
Runtime.getRuntime().exec("cmd.exe /C start /b D:\\test.bat");
Runtime.getRuntime().exec("cmd.exe /C start /b D:\\test.bat");
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
引用一下别人的吧... 求采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.SequenceInputStream;
public class Processing {
public static void main(String[] args) throws InterruptedException {
try {
Process process = Runtime.getRuntime().exec("cmd");
SequenceInputStream sis = new SequenceInputStream(process.getInputStream(), process.getErrorStream());
InputStreamReader isr = new InputStreamReader(sis, "GBK");
BufferedReader br = new BufferedReader(isr);
// next command
OutputStreamWriter osw = new OutputStreamWriter(process.getOutputStream());
BufferedWriter bw = new BufferedWriter(osw);
bw.write("cd /d d:/我的文档/桌面");
bw.newLine();
bw.write("ffmpeg -help");
bw.newLine();
bw.flush();
bw.close();
osw.close();
// read
String line = null;
while (null != (line = br.readLine())) {
System.out.println(line);
}
process.destroy();
br.close();
isr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.SequenceInputStream;
public class Processing {
public static void main(String[] args) throws InterruptedException {
try {
Process process = Runtime.getRuntime().exec("cmd");
SequenceInputStream sis = new SequenceInputStream(process.getInputStream(), process.getErrorStream());
InputStreamReader isr = new InputStreamReader(sis, "GBK");
BufferedReader br = new BufferedReader(isr);
// next command
OutputStreamWriter osw = new OutputStreamWriter(process.getOutputStream());
BufferedWriter bw = new BufferedWriter(osw);
bw.write("cd /d d:/我的文档/桌面");
bw.newLine();
bw.write("ffmpeg -help");
bw.newLine();
bw.flush();
bw.close();
osw.close();
// read
String line = null;
while (null != (line = br.readLine())) {
System.out.println(line);
}
process.destroy();
br.close();
isr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
加上/b就行了
String strcmd = "cmd /c start /b C:\\temp\\ffmpeg.bat " + savePath;
String strcmd = "cmd /c start /b C:\\temp\\ffmpeg.bat " + savePath;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询