clivebuckwheat Posted August 13, 2010 Posted August 13, 2010 Bur I am unsure of the syntax.I need to do the following, pickup the computer name, if it is a specific computer that I am looking for then run a regkey silently.I need to do this for 32 pc's labs.is this right?if /I "%computername%"=="2F16-01" (regedit /s myreg.reg) else (if /I "%computername%"=="2F16-02") (regedit /s myreg2.reg)
iamtheky Posted August 13, 2010 Posted August 13, 2010 (edited) all Edited August 13, 2010 by iamtheky
jaclaz Posted August 13, 2010 Posted August 13, 2010 (edited) IF you have a standard format for computer names, like:2F16-012F16-02....2F16-32Something like this may be more appropriate:@ECHO OFFSETLOCAL ENABLEDELAYEDEXPANSION SET Prefix=2F16- FOR /L %%A IN (1,1,32) DO ( IF %%A leq 9 (SET Num=0%%A) ELSE (SET Num=%%A) ECHO !Num! IF /I "%computername%"=="%Prefix%!Num!" ECHO regedit /s myreg!Num!.reg )Just an example, it will just print on the screen numbers and if the computer name matches the regedit command line.jaclaz Edited August 13, 2010 by jaclaz
Yzöwl Posted August 13, 2010 Posted August 13, 2010 Here's another example for testing, it has been included because the jaclaz version will not actually expand the variables to the console for viewing.@ECHO OFF & SETLOCALSET "Prefix=2F16-"FOR /L %%A IN (1,1,32) DO CALL :SUB 10%%AENDLOCAL & GOTO :EOF:SUBSET "Num=%1"ECHO ONECHO=IF /I "%COMPUTERNAME%"=="%Prefix%%Num:~-2%" REGEDIT /s myreg%Num:~-2%.reg@ECHO OFFAn actual working version would look a little like this:@ECHO OFF & SETLOCALSET "Prefix=2F16-"FOR /L %%A IN (1,1,32) DO CALL :SUB 10%%AENDLOCAL & GOTO :EOF:SUBSET "Num=%1"IF /I "%COMPUTERNAME%"=="%Prefix%%Num:~-2%" REGEDIT /s myreg%Num:~-2%.reg
clivebuckwheat Posted August 14, 2010 Author Posted August 14, 2010 thank you sir it is perfect works like a champ.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now