A
A
axeax2015-05-28 15:31:47
cmd/bat
axeax, 2015-05-28 15:31:47

How to execute a command in bat depending on the presence of a substring in a string?

I'm completely 0 in scripts, tried a lot but nothing happened.
In general, you need to do this in bat:
if there is a substring "xxx" in% computername%, then execute the command [command], otherwise move on

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Spetros, 2015-05-28
@axeax

The FIND command returns different ERRORLEVEL values ​​depending on whether the value you are looking for is found or not.
Next in the script, you need to use the if statement.

Z
ZeroHour, 2015-05-28
@ZeroHour

scriptcoding.ru/2013/08/17/operator-if-cmd

O
Olgeir, 2015-06-18
@Olgeir

echo %computername% | findstr "xxx" && [command]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question