Alright, so I was playing around with changing MTU size and wanted to make a batch file to automatically lower it and then raise it later.
This is probably simple, but I just can't figure it out. Point is, is there a way to run a command, which would normally echo out "ok" but check to see if it does say ok? And if it doesn't say ok then, to end the rest of the file from running and exit out.
The command I'm using is netsh interface ipv4 set subinterface "Local Area Connection" mtu=386 store=persistent which, as I mentioned above prints out an OK. I just want to check if it did run correctly, and if not, then do __
|
|
||||
|
|
|
If netsh is successful it will return an errorlevel of 0 (as do most command-line utilities), essentially meaning "No error". So you should be able to use the command-line
|
|||
|
|
|
The simple answer is to pipe the output through 'grep' and test the output of 'grep':
Typically if there is an error, a program would also return a non-zero exit code (the same as 'grep' will do if it doesn't find the text you are searching for in the case above). I don't know if netsh will do that, but you can probably test by feeding it some illegal values (like 1000000000000). If it does, you can do something slightly simpler:
|
|||
|
|