string manipulation in command promt
Hi,(command prompt) I want to search for the string "virtual" in "system model" attribute of 'sysinfo' command. The command should be successful if 'virtual' is found in the 'system model: -------------------------' i.e. output of the systeminfo. It should not search for 'virtual' in whole output of systeminfo command but should do in system model attribute only. for command --systeminfo | findstr /i "system model" I will get something like--- System Model: HP Compaq dc7800p Small Form Factor in the above line of the output i want to search for string virtual, and want to manipulate using errorlevel. So please help me to do this. following is the one i tried which was not correct. Or help me if i can use regular expressions systeminfo | findstr /i /R "system model: virtual machine" > nul if %errorlevel% == 0 ( echo virtual machine ) ELSE ( echo physical machine ) Thanks in advance
September 17th, 2012 1:25am

In your string make sure you account for the spaces. For example in my case when i run it as following i get one line in return: systeminfo | findstr /R /I /X "System Model: Studio XPS 7100" When i run it as this then it does't work systeminfo | findstr /R /I /X "System Model: Studio XPS 7100"
Free Windows Admin Tool Kit Click here and download it now
September 17th, 2012 2:06am

thanx, helpful
September 17th, 2012 2:11am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics