DOS Batch 让窗户睡觉(并保持睡眠!)

@echo off
@cls

::Tested on a Windows 7 x64 Home Premium machine, but invoking powrprof.dll should work on any xp/
::server 2k3 machine and higher
::Script by Rectifier 06-30-2012

::You WILL need to manually edit the sleepact label to include programs that interrupt sleep

:sleepcheck
set choice=
set /p choice="Enter sleep mode? y/n: "
if not "%choice%"=="" set choice=%choice:~0,1%
if /i "%choice%"=="y" goto sleepact
echo Did not choose yes!!!
goto end

::Programs associated with internet traffic are typical culprits for interrupting sleep mode
::Of these programs, p2p file sharing programs such as utorrent definitely interrupt sleep mode
::MCE Standby Tool is a free program to figure out what is potentially blocking/stopping sleep mode

::Uncomment the example taskkill statments to use them!
::The taskkill command works by using the process name, not the name of the application itself

:sleepact
echo Killing off any netprogs!
echo.
::taskkill /f /im utorrent.exe > nul 2>&1
::taskkill /f /im mirc.exe > nul 2>&1
::taskkill /f /im xchat.exe > nul 2>&1
::taskkill /f /im Steam.exe > nul 2>&1
::taskkill /f /im firefox.exe > nul 2>&1
::taskkill /f /im chrome.exe > nul 2>&1
::taskkill /f /im iexplore.exe > nul 2>&1
::taskkill /f /im opera.exe > nul 2>&1
echo.
echo Sleeping automatically in five seconds!
echo.
choice /c:yn /n /t 5 /d y /m "Do you really want to sleep? y/n: "
set slstatus=%ERRORLEVEL%
if "%slstatus%"=="2" (
echo Sleep cancelled.
goto end
) ELSE (
echo ~SLEEP~ | rundll32.exe powrprof.dll,SetSuspendState 0,1,0
)
goto end

:end
echo TASK DONE
ping 127.0.0.1 -n 2 | find "Reply" > nul
exit /b

DOS Batch ffmpeg - 将iPhone mov文件转换为MPF for JavaFX 2

ffmpeg -i SomeIPhoneMovieFile.mov -c copy SomeIPhoneMovieFile.mp4

DOS Batch 清除SharePoint Deisgner缓存

REM (c) http://Plumsail.com
REM Clear SharePoint Designer cache

rmdir "%LOCALAPPDATA%\Microsoft\WebsiteCache\" /s /q
rmdir "%APPDATA%\Microsoft\SharePoint Designer\ProxyAssemblyCache\" /s /q

DOS Batch GTAV DateFix

@Echo off
:: Check WMIC is available
WMIC.EXE Alias /? >NUL 2>&1 || GOTO s_error

:: Use WMIC to retrieve date and time for Windows XP Professional or Vista/Windows 7
FOR /F "skip=1 tokens=1-6" %%G IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') DO (
   IF "%%~L"=="" goto s_done
      Set _yyyy=%%L
      Set _mm=00%%J
      Set _dd=00%%G
      Set _hour=00%%H
      SET _minute=00%%I
)
:s_done

:: Pad digits with leading zeros
      Set _mm=%_mm:~-2%
      Set _dd=%_dd:~-2%
      Set _hour=%_hour:~-2%
      Set _minute=%_minute:~-2%

::Store current date in a variable called _curdate:
Set _curdate=%_dd%/%_mm%/%_yyyy%
::Change date:
DATE 19/04/2015
::Start Launcher:
CD /d "%~dp0"
start /wait Launcher.exe
pause
::Change date to current date again:
DATE %_curdate%
EXIT

DOS Batch 一次加载Firefox,IE6,Safari和Opera

start "Firefox" "C:\Program Files\Mozilla Firefox\firefox.exe"
start "Internet Explorer" "C:\Program Files\Internet Explorer\IEXPLORE.EXE"
start "Safari" "C:\Program Files\Safari\Safari.exe"
start "Opera" "C:\Program Files\Opera\Opera.exe"
exit

DOS Batch DOS使用NConvert生成缩略图

REM Copy images to processing directory
xcopy /Y /C /I /E C:\Imagery\ToProcess C:\Imagery\Processing\Originals 

REM Copy originals to 200 folder ready for processing
xcopy /Y /C /I /E C:\Imagery\Processing\Originals C:\Imagery\Processing\200x200

REM Convert 200s
for /R C:\Imagery\Processing\200x200 %%I in (*.jpg) do "C:\Program Files\XnView\nconvert.exe" -npcd 2 -size 256x256+0 -ctype grey -corder inter -out jpeg -sharpen 1 -autocrop 10 255 255 255 -ratio -rtype linear -rflag orient -resize 190 190 -bgcolor 255 255 255 -canvas 200 200 center "%%I"

REM All done - copy images to processed directory
xcopy /Y /C /I /E C:\Imagery\Processing\200x200 C:\Imagery\Processed\200x200
xcopy /Y /C /I /E C:\Imagery\Processing\Originals C:\Imagery\Processed\Originals

REM Remove image files from system to prevent repeated conversions of the same images
DEL /F /S /Q "C:\Imagery\Processing\200x200"
DEL /F /S /Q "C:\Imagery\Processing\Originals"
DEL /F /S /Q "C:\Imagery\ToProcess"

DOS Batch DOS计算驱动器上的可用空间

@echo off >nullfile.txt
set Drive=C:
for /F "tokens=7" %%a in ('fsutil volume diskfree %Drive% ^| find /i "# of free"') do set free=%%a
set free=%free:~0,-6%
echo c: %free%

DOS Batch 在网络共享上启用FullTrust

cd c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 
CasPol.exe -m -ag 1.2 -url file://\\ShawnFa-Srv/Tools/* FullTrust

DOS Batch 在Vista中创建符号链接

mklink /D c:\vim "C:\Program Files (x86)\Vim"

DOS Batch DOS命令在路径中运行所有SQL脚本

for %f in ("c:\path\to\dir\*.sql") do sqlcmd -S [SERVER_NAME] -d [DATABASE_NAME] -i "%f" -b