文章目錄
- 截圖
- 息屏
- 鎖屏
- 查看當前的路徑
- 倒計時
- 密碼輸入
- 比較兩個文本的差異
截圖
start snippingtool
息屏
powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)
鎖屏
powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)
rundll32.exe user32.dll LockWorkStation
查看當前的路徑
@echo off
echo 當前盤符:%~d0
echo.
echo 當前路徑:%cd%
echo.
echo 當前盤符和路徑:%~dp0
echo.
echo 當前批處理全路徑:%~f0
echo.
echo 當前盤符和路徑的短檔案名格式:%~sdp0
echo.
echo 當前 CMD 默認目錄:%cd%
echo.
pause
倒計時
@echo off
SET Countdown=30
:Count
set /a Countdown=Countdown-1
ping -n 2 -w 500 127.1>nul
cls
@echo 日期: %date%
@echo.
@echo 時間: %time%
@echo.
@echo 倒計時: %Countdown% 秒
@echo.
if %Countdown%==0 (
<倒計時為 0 時執行的操作>
) else (
goto Count
)
密碼輸入
@echo off
set count = 0
REM REM 設定計數
:Input_password
set /p string=Password:
set /a count = %count% + 1
if "%string%" == "password_123" goto Pass_password
REM REM 如果密碼匹配則進入 Pass_password 代碼塊
if %count% == 3 goto Quit
REM REM 如果嘗試次數達到三次則進入 Quit 代碼塊
goto Input_password
:Pass_password
echo You got the correct password! ^^_^^
REM REM 驗證正確密碼的功能區
:Quit
echo Press any key to continue!
pause>nul
exit
比較兩個文本的差異
@echo off
set n=0
setlocal enabledelayedexpansion
(for /f "delims=" %%i in (test1.txt) do (
set /p str=
set /a n+=1
if not "!str!"=="%%i" (
echo. 第 !n! 行不同!
echo. txt1 第 !n! 行: %%i
echo. txt2 第 !n! 行: !str!
echo.
)
))<"test2.txt"
pause
實作效果如下圖:

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/263764.html
標籤:其他
上一篇:有趣的離線存盤
