在PSTools中使用批处理文件时远程使用set命令时出错

时间:2015-11-29 15:52:54

标签: windows batch-file cmd dns centos7

我想将DNS远程添加到系统中,为此我使用PsExec工具和批处理文件:

**D:\test>set /p add_dns=Enter your DNS
Enter your DNS 192.0.0.1
D:\test>netsh interface ipv4 add dnsservers "LAN" 1
The parameter is incorrect.
'2.0.0.1' is not recognized as an internal or external command,
operable program or batch file.
D:\test>pause**

这在同一系统上工作正常,但对于远程系统则不行:当我输入DNS 192.168.0.1时,它不会占用整个DNS。它显示了这个错误:

public class TrainingActivity extends Activity {

private EditText etIn1, etIn2, etDesired;
private TextView prevInput;

int W[][] = new int[2][];
int X[][] = new int[30][];

int w0=0, w1=0, w2=0, p=1, sum=0, clicks=0;

private Button nxtData;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.training_activity);

    View backgroundImage = findViewById(R.id.background);
    Drawable background = backgroundImage.getBackground();
    background.setAlpha(40);

    etIn1= (EditText) findViewById(R.id.etInput1);
    etIn2 = (EditText) findViewById(R.id.etInput2);
    etDesired = (EditText) findViewById(R.id.etDesired);

    prevInput = (TextView) findViewById(R.id.prevInput);

    nxtData = (Button) findViewById(R.id.nextData);
    nxtData.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            int sum = 0;
            ++clicks;

            int intetIn1 = Integer.parseInt(etIn1.getText().toString());
            int intetIn2 = Integer.parseInt(etIn2.getText().toString());
            int intetDesired = Integer.parseInt(etDesired.getText().toString());

            X[clicks-1] = new int[] {intetIn1, intetIn2, 1};

            prevInput.setText("Last Inputs: (" + intetIn1 + ", " + intetIn2 +
                    ", " + intetDesired + ")");

            if(clicks == 1) {
            if(intetDesired == 1) {
                W[0] = new int[] {intetIn1, intetIn2, 1};
                W[1] = W[0];
            } else if(intetDesired == (-1)){
                W[0] = new int[] {-intetIn1, -intetIn2, -1};
                W[1] = W[0];
            }
            } else if(clicks > 1) {                 
                for(int i=0; i<3; i++){
                    sum = sum + W[clicks-1][i] * X[clicks-1][i];
                } if(sum>0 && intetDesired==1) {
                    W[clicks] = W[clicks-1];
                } else if(sum<0 && intetDesired==(-1)) {
                    W[clicks] = W[clicks-1];
                } else if(sum<=0 && intetDesired==1) {
                    for(int i=0; i<3; i++) {
                    W[clicks][i] = W[clicks-1][i] + X[clicks-1][i];
                }
                } else if(sum>=0 && intetDesired==(-1)) {
                    for(int i=0; i<3; i++) {
                        W[clicks][i] = W[clicks-1][i] - X[clicks-1][i];
                    }
                }
            }   

            Toast.makeText(getApplicationContext(), "" + clicks, 
                    Toast.LENGTH_SHORT).show();
            System.out.println(X[0][0]);

            etIn1.setText("");
            etIn2.setText("");
            etDesired.setText("");

        }
    });


}}

有关如何通过提示输入DNS地址而不是手动输入.bat文件来远程更改DNS的建议吗?

0 个答案:

没有答案