Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

findstr / find using a variable

55 views
Skip to first unread message

j.b...@pfpc.com

unread,
Jun 30, 2008, 11:47:27 AM6/30/08
to
I have a Login_Script that will execute installs and desktop
environments based on the Computer’s name Mostly based on DR Disaster
Recovery Center, SBO Service Bureau Operations, of SBOCC Service
Bureau Operations Command Center

Right now as the script is written each new system has to be add to
the line of code.

A more efficient way would be if there was a conditional findstr or
find that I could use on the variable %comphtername%

So that if findstr/find “SBO” %computername% goto support_staff
If findstr/find “SBOCC” %computername% goto
service_center_scripts
If findstr/find “DR” %computername% goto disaster_center

%computername%
Rem DRR1P1-DRR1P6
Rem DRR2P1-DRR2P6
Rem DRR3P1-DRR3P6
Rem DRR4P1-DRR4P6
Rem DRR5P1-DRR5P6
Rem DRR6P1-DRR6P6

if DRR1P1==%computername% set PClocation=DRC
if DRR1P2==%computername% set PClocation=DRC
if DRR1P3==%computername% set PClocation=DRC
if DRR1P4==%computername% set PClocation=DRC
.
.
.
if DRR6P6==%computername% set PClocation=DRC


rem SB0CCR1P1 – SB0CCR1P6
rem SB0CCR2P1 – SB0CCR2P6
rem SB0CCR3P1 – SB0CCR3P6
rem SB0CCR4P1 – SB0CCR4P6
rem SB0CCR5P1 – SB0CCR5P6

if SBOCCR1P1==%computername% set PClocation=SBOCC
if SBOCCR1P2==%computername% set PClocation=SBOCC
if SBOCCR1P3==%computername% set PClocation=SBOCC
if SBOCCR1P4==%computername% set PClocation=SBOCC
if SBOCCR1P5==%computername% set PClocation=SBOCC
.
.
.
if SBOCCR1P1==%computername% set PClocation=SBOCC

rem TDB
if SBODIR==%computername% goto endofb
rem KSJ
if SBODEV1==%computername% goto endofb
rem CPK
if SBODEV2==%computername% goto endofb
rem SHK
if SBOINT1==%computername% goto endofb
rem RJB
if SBOINT2==%computername% goto endofb
rem DCG
if SBOINT3==%computername% goto endofb
rem JRB
if SBOSUP1==%computername% goto endofb
rem MS
if SBOMGR1==%computername% goto start_printer_services


Thanks in advance

Matthias Tacke

unread,
Jul 1, 2008, 1:55:15 PM7/1/08
to
j.b...@pfpc.com wrote:
> I have a Login_Script that will execute installs and desktop
> environments based on the Computer’s name Mostly based on DR Disaster
> Recovery Center, SBO Service Bureau Operations, of SBOCC Service
> Bureau Operations Command Center
>
> Right now as the script is written each new system has to be add to
> the line of code.
>
> A more efficient way would be if there was a conditional findstr or
> find that I could use on the variable %comphtername%
>
> So that if findstr/find “SBO” %computername% goto support_staff
> If findstr/find “SBOCC” %computername% goto
> service_center_scripts
> If findstr/find “DR” %computername% goto disaster_center
>
> Thanks in advance

You can compare the fixed part directly


if "%computername:~0,2%" EQU "DR" set "PClocation=DRC"&^
goto support_staff
if "%computername:~0,3%" EQU "SBOCC" set "PClocation=SBOCC"&^
goto service_center_scripts

...and so on

The tilde as last char is a line continuation char,
you can put the goto on the same line instead.


HTH
Matthias

0 new messages