'How to check for a certain word in string in batch file
Hope you are doing well guys, I have a problem with batch file.
I have a batch file where user types a PC DNS, there is 4 numbers and 2 letters and again number or 2 numbers for example "1234ds2" or "1234cm02".
For now I have a code looking like this (I'm new at batch so sorry)
@echo off
setlocal EnableExtensions DisableDelayedExpansion
@chcp 1250
Cls
echo Please input the computer name that you want to reset the service:
set /p "salon= "
IF %salon%|findstr /i "ds" (echo "Resetting service for computer %salon% pause)
else (echo Resetting service for PC %salon% pause)
After doing some stuff in PsExec, I want program to pause and let user end the batch file, by clicking any key.
I wanted to do this by finding word "ds", if user inputs it this will go to first IF, resetting specific computer, else this program would reset other PC with "cm" in name. Now I wonder if it wouldn't be better to input 2 IF with "ds" and "cm".
Thanks in advance for help!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
