🧩 Code

cmd code

천하나 2024. 6. 18. 10:41

기본

# 프로그램 종료
taskkill /f /im a.exe

# D to E 미러링
robocopy "D:\Work" "E:\_Drive_D\Work" /mir /zb /r:1

# 모든 파일복사 후 덮어쓰기
robocopy "E:\VM\_hdds\patch" "C:\ProgramData\VMware\VMware Workstation" /xf *

# 강제 복사 
xcopy "E:\Down\a.exe" "D:\Macro" /y

# time out
timeout /t 1

# 프로그램 실행
start D:\Data\a.exe

pc 재부팅 종료

# F 드라이브 부팅
bootsect.exe /nt60 f:

# reboot shutdown fw=cmos
%windir%\System32\shutdown.exe /r /t 1
%windir%\System32\shutdown.exe /s /t 1
%windir%\System32\shutdown.exe /r /fw /t 1

삭제

@echo off
cd /d D:\Work\Pic\Screenshots
for /r %%i in (*) do (
    if not "%%~xi"==".cmd" (
        del "%%i"
    )
)

host block

# firewall block
netsh advfirewall firewall add rule name="adobe ps" dir=out action=block program="D:\Apps\Studio\Adobe\Adobe.Photoshop\App\Program Files\Adobe\Adobe Photoshop 2024\Photoshop.exe" enable=yes
netsh advfirewall firewall add rule name="adobe pre" dir=out action=block program="D:\Apps\Studio\Adobe\Adobe Premiere Pro\Adobe Premiere Pro.exe" enable=yes
netsh advfirewall firewall add rule name="adobe med" dir=out action=block program=""D:\Apps\Studio\Adobe\Adobe Media Encoder\Adobe Media Encoder.exe" enable=yes

# open host
notepad %SystemRoot%\system32\drivers\etc\hosts


# host block
@echo off
SET HOSTS_PATH=%windir%\System32\drivers\etc\hosts

:: Check if the script is running as Administrator
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

:: If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
    "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
    pushd "%CD%"
    CD /D "%~dp0"

:: Add entries to the hosts file
echo Adding entries to the hosts file...
echo 127.0.0.1 activate.adobe.com >> %HOSTS_PATH%
echo 127.0.0.1 practivate.adobe.com >> %HOSTS_PATH%
echo 127.0.0.1 lmlicenses.wip4.adobe.com >> %HOSTS_PATH%
echo Entries added successfully.

:: Optional - Flush DNS to apply changes immediately
ipconfig /flushdns

:: Close the Command Prompt window
exit