If any string exists in the computer name, the condition should be set to true [closed]











up vote
2
down vote

favorite












I am trying to check if a Computer name has BKUP, NAS, PLAYER, or BACKUP in any part of its name through a batch script. If the condition is true I will run an additional command to create a network share on that computer.



This is my batch file:



echo off
setlocal EnableDelayedExpansion

REM skip lines 1 read lines 2 in PRORGRAMS OUTPUT
@For /F "skip=1 tokens=1" %%u IN ('WMIC computersystem get name^) do (
SET "TRUE="
IF x%%u BKUP TRUE=1
IF x%%u NAS TRUE=1
IF x%%u PLAYER TRUE-1
IF x%%u BACKUP TRUE=1









share|improve this question















closed as unclear what you're asking by DavidPostill Nov 13 at 21:31


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.















  • I am asking for the correct method of scripting.
    – David Greenway
    Nov 13 at 21:55










  • The easiest way is probably IF NOT "%COMPUTERNAME%"=="%COMPUTERNAME:BKUP=%" SET TRUE=1, etc. You don't need to use the FOR loop this way since you don't need WMIC. Take a look at this.
    – Worthwelle
    Nov 13 at 23:44

















up vote
2
down vote

favorite












I am trying to check if a Computer name has BKUP, NAS, PLAYER, or BACKUP in any part of its name through a batch script. If the condition is true I will run an additional command to create a network share on that computer.



This is my batch file:



echo off
setlocal EnableDelayedExpansion

REM skip lines 1 read lines 2 in PRORGRAMS OUTPUT
@For /F "skip=1 tokens=1" %%u IN ('WMIC computersystem get name^) do (
SET "TRUE="
IF x%%u BKUP TRUE=1
IF x%%u NAS TRUE=1
IF x%%u PLAYER TRUE-1
IF x%%u BACKUP TRUE=1









share|improve this question















closed as unclear what you're asking by DavidPostill Nov 13 at 21:31


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.















  • I am asking for the correct method of scripting.
    – David Greenway
    Nov 13 at 21:55










  • The easiest way is probably IF NOT "%COMPUTERNAME%"=="%COMPUTERNAME:BKUP=%" SET TRUE=1, etc. You don't need to use the FOR loop this way since you don't need WMIC. Take a look at this.
    – Worthwelle
    Nov 13 at 23:44















up vote
2
down vote

favorite









up vote
2
down vote

favorite











I am trying to check if a Computer name has BKUP, NAS, PLAYER, or BACKUP in any part of its name through a batch script. If the condition is true I will run an additional command to create a network share on that computer.



This is my batch file:



echo off
setlocal EnableDelayedExpansion

REM skip lines 1 read lines 2 in PRORGRAMS OUTPUT
@For /F "skip=1 tokens=1" %%u IN ('WMIC computersystem get name^) do (
SET "TRUE="
IF x%%u BKUP TRUE=1
IF x%%u NAS TRUE=1
IF x%%u PLAYER TRUE-1
IF x%%u BACKUP TRUE=1









share|improve this question















I am trying to check if a Computer name has BKUP, NAS, PLAYER, or BACKUP in any part of its name through a batch script. If the condition is true I will run an additional command to create a network share on that computer.



This is my batch file:



echo off
setlocal EnableDelayedExpansion

REM skip lines 1 read lines 2 in PRORGRAMS OUTPUT
@For /F "skip=1 tokens=1" %%u IN ('WMIC computersystem get name^) do (
SET "TRUE="
IF x%%u BKUP TRUE=1
IF x%%u NAS TRUE=1
IF x%%u PLAYER TRUE-1
IF x%%u BACKUP TRUE=1






batch-file






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 at 21:30









zx485

556313




556313










asked Nov 13 at 21:05









David Greenway

111




111




closed as unclear what you're asking by DavidPostill Nov 13 at 21:31


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as unclear what you're asking by DavidPostill Nov 13 at 21:31


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • I am asking for the correct method of scripting.
    – David Greenway
    Nov 13 at 21:55










  • The easiest way is probably IF NOT "%COMPUTERNAME%"=="%COMPUTERNAME:BKUP=%" SET TRUE=1, etc. You don't need to use the FOR loop this way since you don't need WMIC. Take a look at this.
    – Worthwelle
    Nov 13 at 23:44




















  • I am asking for the correct method of scripting.
    – David Greenway
    Nov 13 at 21:55










  • The easiest way is probably IF NOT "%COMPUTERNAME%"=="%COMPUTERNAME:BKUP=%" SET TRUE=1, etc. You don't need to use the FOR loop this way since you don't need WMIC. Take a look at this.
    – Worthwelle
    Nov 13 at 23:44


















I am asking for the correct method of scripting.
– David Greenway
Nov 13 at 21:55




I am asking for the correct method of scripting.
– David Greenway
Nov 13 at 21:55












The easiest way is probably IF NOT "%COMPUTERNAME%"=="%COMPUTERNAME:BKUP=%" SET TRUE=1, etc. You don't need to use the FOR loop this way since you don't need WMIC. Take a look at this.
– Worthwelle
Nov 13 at 23:44






The easiest way is probably IF NOT "%COMPUTERNAME%"=="%COMPUTERNAME:BKUP=%" SET TRUE=1, etc. You don't need to use the FOR loop this way since you don't need WMIC. Take a look at this.
– Worthwelle
Nov 13 at 23:44

















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Сан-Квентин

Алькесар

8-я гвардейская общевойсковая армия