感恩彰興國中陳宏盈組長協助
一鍵完成電腦手動校時
當電腦主機無法自動校時,如何手動校時?一步一步設定太麻煩了,可不可寫個BAT,用滑鼠點兩下就完成校時呢?
一鍵設定電腦開機自動校時
當電腦主機無法自動校時,如何開機完成後就進行校時。一步一步設定太麻煩了,可不可寫個bat,當主機開完機,就自動進行校時。
如何使用?
1.請先確認
2.檔案下載,解壓密碼demo1234
3.解壓縮AutoNtpDate.rar->產生資料夾AutoNtpDate
4.對資料夾AutoNtpDate內的Copy2Startup.bat點兩下,即完成設定。
一鍵完成電腦主機手動校時
檔名:NtpDate.BAT
內容:
@echo off
REM :: BatchGotAdmin (Run as Admin code starts)
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> 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"
REM :: BatchGotAdmin (Run as Admin code ends)
REM :: Your codes should start from the following line
@echo off
net start w32time
w32tm /config /update /manualpeerlist:"time.stdtime.gov.tw,0x1 watch.stdtime.gov.tw,0x1"
w32tm /resync
net stop w32time
PAUSE
EXIT
將NtpDate.BAT複製到開機啟動資料夾,重啟電腦主機
檔名:Copy2Startup.BAT
內容:
@echo off
REM :: BatchGotAdmin (Run as Admin code starts)
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> 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"
REM :: BatchGotAdmin (Run as Admin code ends)
REM :: Your codes should start from the following line
@echo off
copy "%~dp0\NtpDate.BAT" "%HomePath%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
shutdown /r /f /t 0
沒有留言:
張貼留言