简体   繁体   中英

Running CMD code in Visual Studio Windows Form

How can I use the following CMD codes in Visual Studio Windows Form?

1-) nslookup xxxx.yyy.com | FIND /i "192.168.1.88" > c:\temp\nslookup.txt

2-) reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Symantec\Symantec Endpoint Protection\SMC\SYLINK\SyLink" /v "CurrentGroup" > C:\Temp\SymantecKontrol.txt

3-) find /i "Laptopimage" C:\temp\SymantecControl.txt >NUL if %errorlevel% equ 1 goto notfound1

FORM-1 OPEN<<<<<<

goto done

:notfound1

find /c "192.168" C:\temp\nslookup.txt >NUL if %errorlevel% equ 1 goto notfound

FORM-2 OPEN<<<<<<

goto done:notfound

FORM-3 OPEN<<<<<<

If you want to run the commands separately you can do the following:

using System.Diagnostics;

string commandExample = "echo Hello!";
Process.Start($"cmd.exe /c {commandExample}");

or you can run the batch script:

Process.Start("script.bat");
Console.ReadLine();//not needed if you are running it under Windows 
Forms template

By my knowledge I don't think it's possible to open a form from batch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM