https://learn.microsoft.com/ko-kr/powershell/module/microsoft.powershell.core/about/about_regular_expressions?view=powershell-7.3
schtasks /query /fo LIST /v > d:\txt2.txt
findstr /c:"OneDrive" d:\txt2.txt > d:\test.txt
[ -~]* 전체를 의미 하네요 앞에 쓰면 앞에 전체 나머지 뒤에 쓰면 뒤에 전체 나머지를 의미 하네요 좋아요 ㅎㅎ
[ -~]*홍길동 이럴 경우 홍길동과 함께 오른쪽이 모두 제거 된다 단 한국어는 제거 안된다 -_-;; 영어로 바꺼야함
[ -~]* 샵범뒤 제거 빈줄 제거 빈텝 제거 \ 특수 키를 입력 하기 전에 넣는 것이다 \[
홍길동[ -~]* 마찬가지로 왼쪽 문자가 모두 제거 된다.
원래는 '홍길동[ -~]*,'복자' 이런식으로 해야 하는대 구차니즘 ㅎ '홍길동[ -~]*,'' 그냥 안쓰면 제거 된다.
\과 일치 하는 줄 모두 제거 \도 함께 제거
PowerShell -Command "& {Get-Content d:\test.txt | %{$_ -replace '[ -~]* \\'} > d:\out444.txt}"
나머지 찌꺼기 모두 제거
PowerShell -Command "& {Get-Content d:\out444.txt | %{$_ -replace 'Task To Run[ -~]*'} > d:\out555.txt}"
chcp 65001
한글로 나오면 제거가 어려운대 영문으로 바꾸면 쉽다.
배치파일 영문 환경으로 변경
chcp 949 한글 환경으로 변경 할 경우.
https://learn.microsoft.com/ko-kr/powershell/module/microsoft.powershell.core/about/about_regular_expressions?view=powershell-7.3
[ -~]* 샵범위 제거 빈줄 제거 빈텝 제거 \ 특수 키를 입력 하기 전에 넣는 것이다 \[
PowerShell -Command "& {Get-Content d:\test.txt | %{$_ -replace '[ -~]* \\'} > d:\out444.txt}"
나머지 찌꺼기 Task To Run 문장 나머지 제거
PowerShell -Command "& {Get-Content d:\out444.txt | %{$_ -replace 'Task To Run[ -~]*'} > d:\out555.txt}"
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_character_encoding?view=powershell-7.3 인코딩 리스트가 있다.
https://stricky.tistory.com/160 인코딩 쉽게 변경 하기 이분 밖에 없었음 설명 하는 이가 ㅋㅋ.. 대박 겨우 찾음.
UTF16으로 되는대 그럼 findstr에서 검색이 안됨 그래서 인코딩 변경
PowerShell -Command "& {Get-Content d:\out555.txt | Set-Content d:\77777.txt -Encoding utf7}"
원하는 파일 검색 https://github.com/oklokl/advfirewall-ip-list-firehol_level1.netset/blob/main/Batchfile_drop/revmoe05.bat
문자열 추출하기
findstr /c:"OneDrive Standalone Update Task" d:\77777.txt
장치 관리자 걸러 내는걸로 걸러 냈다 ㅎㅎ 휴 https://cafe.daum.net/candan/I45j/75
For /F "Delims=" %G In ('findstr /c:"OneDrive Standalone Update Task" d:\77777.txt 2^>NUL') Do schtasks /change /tn "%G" /disable
성공 ㅎㅎ 휴..
For /F "Delims=" %G In ('findstr /c:"OneDrive Reporting Task" d:\77777.txt 2^>NUL') Do schtasks /change /tn "%G" /disable
다른 애도 걸러 내기.
윈도우키 + R
taskschd.msc
chcp 65001
schtasks /query /fo LIST /v > d:\txt2.txt
findstr /c:"OneDrive" d:\txt2.txt > d:\test.txt
PowerShell -Command "& {Get-Content d:\test.txt | %{$_ -replace '[ -~]* \\'} > d:\out444.txt}"
PowerShell -Command "& {Get-Content d:\out444.txt | %{$_ -replace 'Task To Run[ -~]*'} > d:\out555.txt}"
PowerShell -Command "& {Get-Content d:\out555.txt | Set-Content d:\77777.txt -Encoding utf7}"
echo "되는지 보기" 두줄이 나오면 정상이다"
findstr /c:"OneDrive Standalone Update Task" d:\77777.txt
For /F "Delims=" %G In ('findstr /c:"OneDrive Standalone Update Task" d:\77777.txt 2^>NUL') Do schtasks /change /tn "%G" /disable
For /F "Delims=" %G In ('findstr /c:"OneDrive Reporting Task" d:\77777.txt 2^>NUL') Do schtasks /change /tn "%G" /disable
chcp 949
거시기 파일 temp 폴더에 생기게 하기 ㅎㅎ 초보자는 이게 최선이다 ㅠ.
chcp 65001
schtasks /query /fo LIST /v > %temp%\txt2.txt
findstr /c:"OneDrive" %temp%\txt2.txt > %temp%\test.txt
PowerShell -Command "& {Get-Content %temp%\test.txt | %{$_ -replace '[ -~]* \\'} > %temp%\out444.txt}"
PowerShell -Command "& {Get-Content %temp%\out444.txt | %{$_ -replace 'Task To Run[ -~]*'} > %temp%\out555.txt}"
PowerShell -Command "& {Get-Content %temp%\out555.txt | Set-Content %temp%\77777.txt -Encoding utf7}"
echo "되는지 보기" 두줄이 나오면 정상이다"
findstr /c:"OneDrive Standalone Update Task" %temp%\77777.txt
For /F "Delims=" %G In ('findstr /c:"OneDrive Standalone Update Task" %temp%\77777.txt 2^>NUL') Do schtasks /change /tn "%G" /disable
For /F "Delims=" %G In ('findstr /c:"OneDrive Reporting Task" %temp%\77777.txt 2^>NUL') Do schtasks /change /tn "%G" /disable
chcp 949
PowerShell -Command "& {Get-Content """"%temp%\test.txt"""" | %{$_ -replace '[ -~]* \\'} | %{$_ -replace 'Task To Run[ -~]*'} > """"%temp%\out555.txt""""}"
이렇게 해도 되네요.
https://kin.naver.com/qna/detail.naver?d1id=1&dirId=104&docId=433076909 모꼬모지님께서 한줄로 해결 하는거 알려 주셨네요 ㅎㅎ 대단.
for /f "tokens=2* delims= " %f in ('schtasks /query /fo list /v ^|findstr/irc:".*Onedrive.*task.*"') do (call schtasks /change /tn "%~g" /disable)
https://m.blog.naver.com/sung_mk1919/221773181482 모모님 명령어의 설명 이네요.
token=2* 글의 두번째 모두 카피 하라는 명령어 같아요.
for /f "tokens=2* delims= " %f in ('type d:\txt2.txt ^|findstr/irc:".*Onedrive.*task.*"') do (echo "%~g")
for /f "tokens=3* delims= " %f in ('type d:\txt2.txt ^|findstr/irc:".*Onedrive.*task.*"') do (echo "%~g")
이런 식인거죠
첫댓글 문자는 파일이 uff-16으로 된다 ㅋㅋ;;
https://stricky.tistory.com/160
Get-Content <원본파일경로&이름> | Set-Content <변경후 저장 파일경로&이름> -Encoding UTF8
PowerShell -Command "& {Get-Content d:\out555.txt | Set-Content d:\77777.txt -Encoding UTF8}"
겨우 성공
PowerShell -Command "& {Get-Content d:\out555.txt | %{Set-Content -Value -Encoding UTF8} > d:\77777.txt }" 어렵다 잘 안됨 ㅋㅋ 나오질 않는다. 실패.
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_character_encoding?view=powershell-7.3
이놈의 인코딩 사람 잡내 ㅋ
PowerShell -Command "& {Get-Content d:\out555.txt | Set-Content d:\77777.txt -Encoding utf7}"
이걸 해내내 -_- 이렇게 하면 utf-8이 된다
https://cafe.daum.net/candan/I45j/75 추출 하기
For /F "Delims=" %G In ('findstr /c:"OneDrive Standalone Update Task" d:\77777.txt 2^>NUL') Do echo %G