| 1. |
Solve : How to open a file and examine its contents? |
|
Answer» Hi, you might be abe to pipe the output directly to a SET statementI like this. Regards coucou The solution above was for inclusion in a batch file. At the command line, the proper format is: for /f "delims=!" %a in (chkfile.dat) do echo %a Just another example of the DOS follies. TNX agin Sidewinder, Finally here my command for /f "delims=!" %a in (chkfile.dat) do set check=%a and here my small cmd Code: [Select]@echo off set vm=Runing inside VMWare <version 6>. start / wait vmchk.exe >chkfile.dat for /f "delims=!" %%a in (chkfile.dat) do set check=%%a If vm=check Then vmtools.exe else endif It is correct? It is there anyhow to pipe directly vmchk.exe >to_a_variable instead of to a file? If so, let me KNOW how. Regards coucouYou may be confusing redirection with piping. Redirection is used with devices (stdin, stdout, stderror, nul). The pipe is used to send data from one command to another. Code: [Select] for /f "delims=!" %%a in ('vmchk') do set check=%%a if %check%=vm vmtools From your previous posts, I thought %check% would resolve to "Runing inside VMWare ." or "Not runing inside VMWare.". If that's the case %check% will never equal the literal vm. The command interpreter does not support a if/then/else/endif construct. Hope this helps. I tested my small cmd in many ways without success. What I'm looking to do is by launching vmcheck.cmd it will 1)call vmchk.exe 2)Check IN chkfile.dat file or a variable for "Runing inside VMWare <version 6>." text 3) IF so run vmtools .exe 4) else 5) endif or exit or stop the program runing Have you any suggestion?Woowww!!! it works Here the Code: [Select]@echo off set vm=Runing inside VMWare <version 6>. vmchk.exe >chkfile.dat for /f "delims=!" %%a in (chkfile.dat) do set check=%%a If "%check%" == "%vm%" vmtools.exe I had not success to pipe the returned message "Runing inside VMWare <version 6>." from vmchk.exe >to_a_variable without using chkfile.dat file Regards coucouIf you want to go straight to a variable, the syntax is different: Code: [Select] for /f %%a in ('vmchk') do ( if %%a=Running vmtools ) Wooww! It works with 2 == Code: [Select]for /f %%a in ('vmchk') do ( if "%%a=="Runing inside VMWare <version 6>." vmtools.exe ) coucou |
|