if -> 조건이 참이면 수행
if not -> 조건이 거짓이면 수행
if exist 파일명 -> 파일이 존재하면 수행
if /i -> 대소문자에 관계없이 문자열 비교
if "str1"=="str2" -> 문자열이 같으면 수행
for /l %변수 in (초기값, 증가값, 최대값) do 명령 -> 증가 또는 감소하는 for문
for /f "옵션" %변수 in (파일명) do 명령 -> 파일 내용을 범위로 사용
skip=숫자 -> 무시할 행의 수
delims=문자 -> 각 행의 구분자, 기본값은 공백
tokens=범위 -> 각 행에서 사용할 토큰
C:\>copy con test.txt
test first number 1
test second number 2
test third number 3
^Z
1개 파일이 복사되었습니다.
C:\>copy con for.bat
@echo off
for /f %%a in (test.txt) do echo %%a
for /f "delims=" %%a in (test.txt) do echo %%a
for /f "skip=2 tokens=1,2*" %%a in (test.txt) do echo %%b & echo %%c
1개 파일이 복사되었습니다.
----------------
보고서
net user
[윈도우 기본 보안 설정]
secedit /export /cfg 파일명.inf
1. Administrator 계정 존재시 이름 변경.
- 계정명 변경 명령어
ex> wmic useraccount where name='Administrator' rename 'i2sec'
2. Guest 계정 활성화시 비활성화 변경.
- guest 계정 비활성화
ex> net user Guest /active:no
----
예제
@echo off
secedit /export /cfg i2sec.inf
setlocal
echo [Administrator 계정 관리] :
for /f "skip=11 tokens=1,2,3" %%a in ('type i2sec.inf') do (
if /i "%%c" EQU ""Administrator"" (
echo Administrator 계정 발견
set /p guest=Administrator 계정 이름을 변경하시겠습니까?[Y/N] :
set /p name=변경할 계정명을 입력하세요 :
)
)
echo.
if /i "%guest%" EQU "Y" (
wmic useraccount where name='Administrator' rename '%name%'
) else (
echo Administrator 계정 없음
)
net user Guest /active:yes
echo Guest 계정 비활성 [OK]
'System ' 카테고리의 다른 글
understanding utf -8 (video clip) (0) | 2015.06.21 |
---|---|
shell programming (0) | 2014.10.08 |
stack / heap bof (0) | 2014.10.02 |
nop BOF (0) | 2014.10.01 |
basic start of BOF (0) | 2014.09.30 |