Answer the question
In order to leave comments, you need to log in
How to use a .bat file to perform a certain action depending on the name of the computer on which the file is being executed?
Good afternoon, please tell me if it is possible to check a part of the computer name using the .bat file and, based on this, perform this or that action
Namely, there are 5 computers with the following names:
Answer the question
In order to leave comments, you need to log in
Approximately like this:
@echo off
rem Имя компьютера из переменной окружения COMPUTERNAME
set fullName=%COMPUTERNAME%
rem echo %fullName%
rem Первые три симовла имени
set subName=%fullName:~0,3%
rem echo %subName%
rem Если имя начинается на 001 вывести true иначе false
IF %subName%==001 (echo true) ELSE (echo false)
rem Если имя начинается на 002 вывести true иначе false
IF %subName%==002 (echo true) ELSE (echo false)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question