I have some data in a text file called mData.txt, data looks like this :
Master1:H1M1,H2M1
Master2:H1M2,H7M2
VMVPC092015:H1,H2,H3
DEKSTOP-UKUEA78:Machine1,Machine2
Master4:H1M4,H2M4
Here's some sample code from my batch file :
@echo off
setLocal enableDelayedExpansion
:: Set hostname
hostname.exe > __hName.tmp
set /p hNameVar=<__hName.tmp
del __hName.tmp
echo %hNameVar%
for /f "usebackq" %%i IN (`hostname`) do set hNameVar2=%%i
echo %hNameVar2%
for /f "tokens=1,2 delims=:" %%a in (mData.txt) do (
set mName=%%a
set hName=%%b
if !mName!==%hNameVar2% (
echo FoundIt
pause
)else (
echo here: !mName!
echo there: !hNameVar2!
)
)
The name of my desktop is : DESKTOP-UKUEA78
I want this script to read the first machine name from each line in the text file and find out if that machine name is equal to the name of my desktop.
The execution is continuously going into else clause. I've attached a screenshot as well. hNameVar and hNameVar2 both are producing same o/p.ScreenShot This is my first batch project and I can't quite figure out where I'm going wrong. Would someone help me out please...