}
public void setGateway(String gateway)
{
this.gateway = gateway;
}
public String getGwmetric()
{
return gwmetric;
}
public void setGwmetric(String gwmetric)
{
this.gwmetric = gwmetric;
}
public String getDns_first()
{
return dns_first;
}
public void setDns_first(String dnsFirst)
{
dns_first = dnsFirst;
}
public String getDns_remark()
{
return dns_remark;
}
public void setDns_remark(String dnsRemark)
{
dns_remark = dnsRemark;
}
public String getFile_url()
{
return file_url;
}
public void setFile_url(String fileUrl)
{
file_url = fileUrl;
}
public String getWeb_count()
{
return web_count;
}
public void setWeb_count(String webCount)
{
web_count = webCount;
}
public String getWeb_url()
{
return web_url;
}
public void setWeb_url(String webUrl)
{
web_url = webUrl;
}
public String getConfigFileName()
{
return this.configFileName;
}
public void setConfigFileName(String cfgFileName)
{
this.configFileName = cfgFileName;
}
4. ExecCmd.java 类
package com.zhangzhen.cmd;
import java.io.File;
import java.io.IOException;
public class ExecCmd
{
//Runtime runtime ;
public static void exec(SystemVars configInfo)
{
String cmd = "netsh -f "+configInfo.getFile_url()+configInfo.getConfigFileName()+".txt";
try
{
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(cmd);
}
catch(IOException e)
{
System.out.println("+------>"+e.getMessage());
}
}
public static void dhcp()
{
File dhcp = new File("D:\IP_CONFIG\dhcp.txt");
String [] str = new String[5];
str[0]="pushd interface ip";
str[1]="set address name="+"本地连接 "+"source=dhcp";
str[2]="set dns name="+"本地连接 "+"source=dhcp register=PRIMARY ";
str[3]="set wins name="+"本地连接 "+"source=dhcp";
str[4]="popd";
try
{
dhcp.createNewFile();
}
catch(IOException ie)
{
ie.printStackTrace();
}
ConfigFile.createFile("D:\IP_CONFIG\dhcp.txt", str);
String cmd = "netsh -f "+"D:\IP_CONFIG\dhcp.txt";
try
{
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(cmd);
}
catch(IOException e)
{
System.out.println("+------>"+e.getMessage());
}
}
}