cmd修改dns指令

try {
        	Runtime run=Runtime.getRuntime();
			Process p= run.exec("netsh interface ip set dns \"本地连接 6\" source=static addr=8.8.8.8");
			Reader in=new InputStreamReader(p.getInputStream());
			BufferedReader inb=new BufferedReader(in);
			while(true) {
				String s=inb.readLine();
				if(s==null)break;
				System.out.println(s);
			}
		} catch (IOException e1) {
			e1.printStackTrace();
		}
netsh interface ip set dns \"本地连接 6\" source=static addr=8.8.8.8
netsh interface ip add dns \"本地连接 6\" addr=8.8.8.8

猜你喜欢

转载自blog.csdn.net/u010756046/article/details/80675429