『楼 主』:
记录开机和关机时间及机器运行时间
::记录开机和关机时间及机器运行时间,傻瓜式安装,不用手工了.呵呵..
@echo off
chcp|find "936" >nul 2>nul
if "%ERRORLEVEL%"=="1" (echo 您的操作系统不是中文版!"可能"无法记录开关机时间.) else (echo 您的操作系统是中文版!)
ver|find "2000" > nul 2>nul
if "%ERRORLEVEL%"=="0" (echo 你的操作系统是Windows 2000!"可能"无法记录开关机时间.&goto :log)
ver|find "XP" > nul 2>nul
if "%ERRORLEVEL%"=="0" (echo 你的操作系统是Windows xp!&goto :log)
echo 您的操作系统不是Windows 2000或者Windows XP,"可能"无法记录开关机时间.
:log
if exist %windir%\system32\systeminfo.exe (
echo 找到所需文件,开始安装!
) else (
echo 找不到所需文件,日志将失去部分记录.
)
::记录开机时间
echo @echo off>logon.bat
echo echo ------------------------------------------^>^>%%windir%%\Logon.txt>>logon.bat
echo echo 登陆时间:%%date%%,%%time%% ^>^>%%windir%%\Logon.txt>>logon.bat
echo echo 登陆用户名:%%USERNAME%%^>^>%%windir%%\Logon.txt>>logon.bat
echo exit>>logon.bat
::记录关机时间
echo @echo off>logoff.bat
echo echo 请稍候...>>logoff.bat
echo for /f "skip=11 delims=秒" %%%%%i in ('systeminfo') do (>>logoff.bat
echo echo "%%%%i秒" ^>^>%%windir%%\Logon.txt>>logoff.bat
echo echo 注消时间:%%date%%,%%time%% ^>^>%%windir%%\Logon.txt>>logoff.bat
echo echo ------------------------------------------^>^>%%windir%%\Logon.txt>>logoff.bat
echo echo.^>^>%%windir%%\Logon.txt>>logoff.bat
echo exit>>logoff.bat
echo )>>logoff.bat
copy logon.bat d:\ & copy logoff.bat d:\
pause
::看看有没有成功,判断一下,顺便加上属性.保险...
:att
if exist d:\logon.bat (attrib +a +s +r +h d:\logon.bat) else (goto :att)
if exist d:\logoff.bat (attrib +a +s +r +h d:\logoff.bat) else (goto :att)
echo 文件创建成功!
echo 加入注册表,这是成功的一部分.windows发出提示时请点击确定.
echo Windows Registry Editor Version 5.00>>log.reg
echo [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts]>>log.reg
echo [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logoff]>>log.reg
echo [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0]>>log.reg
echo "GPO-ID"="LocalGPO">>log.reg
echo "SOM-ID"="Local">>log.reg
echo "FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\User">>log.reg
echo "DisplayName"="Local Group Policy">>log.reg
echo "GPOName"="Local Group Policy">>log.reg
echo [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0\0]>>log.reg
echo "Script"="D:\\logoff.bat">>log.reg
echo "Parameters"="">>log.reg
echo "ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00>>log.reg
echo [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logon]>>log.reg
echo [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logon\0]>>log.reg
echo "GPO-ID"="LocalGPO">>log.reg
echo "SOM-ID"="Local">>log.reg
echo "FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\User">>log.reg
echo "DisplayName"="Local Group Policy">>log.reg
echo "GPOName"="Local Group Policy">>log.reg
echo [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logon\0\0]>>log.reg
echo "Script"="D:\\logon.bat">>log.reg
echo "Parameters"="">>log.reg
echo "ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00>>log.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\S-1-5-21-1960408961-115176313-725345543-1004\Scripts]>>log.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\S-1-5-21-1960408961-115176313-725345543-1004\Scripts\Logoff]>>log.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\S-1-5-21-1960408961-115176313-725345543-1004\Scripts\Logoff\0]>>log.reg
echo "GPO-ID"="LocalGPO">>log.reg
echo "SOM-ID"="Local">>log.reg
echo "FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\User">>log.reg
echo "DisplayName"="Local Group Policy">>log.reg
echo "GPOName"="Local Group Policy">>log.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\S-1-5-21-1960408961-115176313-725345543-1004\Scripts\Logoff\0\0]>>log.reg
echo "Script"="D:\\logoff.bat">>log.reg
echo "Parameters"="">>log.reg
echo "ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00>>log.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\S-1-5-21-1960408961-115176313-725345543-1004\Scripts\Logon]>>log.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\S-1-5-21-1960408961-115176313-725345543-1004\Scripts\Logon\0]>>log.reg
echo "GPO-ID"="LocalGPO">>log.reg
echo "SOM-ID"="Local">>log.reg
echo "FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\User">>log.reg
echo "DisplayName"="Local Group Policy">>log.reg
echo "GPOName"="Local Group Policy">>log.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\S-1-5-21-1960408961-115176313-725345543-1004\Scripts\Logon\0\0]>>log.reg
echo "Script"="D:\\logon.bat">>log.reg
echo "Parameters"="">>log.reg
echo "ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00>>log.reg
echo [HKEY_USERS\S-1-5-21-1960408961-115176313-725345543-1004\Software\Policies\Microsoft\Windows\System\Scripts]>>log.reg
echo [HKEY_USERS\S-1-5-21-1960408961-115176313-725345543-1004\Software\Policies\Microsoft\Windows\System\Scripts\Logoff]>>log.reg
echo [HKEY_USERS\S-1-5-21-1960408961-115176313-725345543-1004\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0]>>log.reg
echo "GPO-ID"="LocalGPO">>log.reg
echo "SOM-ID"="Local">>log.reg
echo "FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\User">>log.reg
echo "DisplayName"="Local Group Policy">>log.reg
echo "GPOName"="Local Group Policy">>log.reg
echo [HKEY_USERS\S-1-5-21-1960408961-115176313-725345543-1004\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0\0]>>log.reg
echo "Script"="D:\\logoff.bat">>log.reg
echo "Parameters"="">>log.reg
echo "ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00>>log.reg
echo [HKEY_USERS\S-1-5-21-1960408961-115176313-725345543-1004\Software\Policies\Microsoft\Windows\System\Scripts\Logon]>>log.reg
echo [HKEY_USERS\S-1-5-21-1960408961-115176313-725345543-1004\Software\Policies\Microsoft\Windows\System\Scripts\Logon\0]>>log.reg
echo "GPO-ID"="LocalGPO">>log.reg
echo "SOM-ID"="Local">>log.reg
echo "FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\User">>log.reg
echo "DisplayName"="Local Group Policy">>log.reg
echo "GPOName"="Local Group Policy">>log.reg
echo [HKEY_USERS\S-1-5-21-1960408961-115176313-725345543-1004\Software\Policies\Microsoft\Windows\System\Scripts\Logon\0\0]>>log.reg
echo "Script"="D:\\logon.bat">>log.reg
echo "Parameters"="">>log.reg
echo "ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00Windows>>log.reg
echo [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts]>>log.reg
echo [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logoff]>>log.reg
echo [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0]>>log.reg
echo "GPO-ID"="LocalGPO">>log.reg
echo "SOM-ID"="Local">>log.reg
echo "FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\User">>log.reg
echo [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0\0]>>log.reg
echo "Script"="D:\\logoff.bat">>log.reg
echo "Parameters"="">>log.reg
echo "ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00>>log.reg
echo [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logon]>>log.reg
echo [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logon\0]>>log.reg
echo "GPO-ID"="LocalGPO">>log.reg
echo "SOM-ID"="Local">>log.reg
echo "FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\User">>log.reg
echo [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logon\0\0]>>log.reg
echo "Script"="D:\\logon.bat">>log.reg
echo "Parameters"="">>log.reg
echo "ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00>>log.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group>>log.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group>>log.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group>>log.reg
echo "GPO-ID"="LocalGPO">>log.reg
echo "SOM-ID"="Local">>log.reg
echo "FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\User">>log.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group>>log.reg
echo "Script"="D:\\logoff.bat">>log.reg
echo "Parameters"="">>log.reg
echo "ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00>>log.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group>>log.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group>>log.reg
echo "GPO-ID"="LocalGPO">>log.reg
echo "SOM-ID"="Local">>log.reg
echo "FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\User">>log.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group>>log.reg
echo "Script"="D:\\logon.bat">>log.reg
echo "Parameters"="">>log.reg
echo "ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00>>log.reg
echo [HKEY_USERS\S-1-5-21-1960408961-115176313-725345543-1004\Software\Policies\Microsoft\Windows\System\Scripts]>>log.reg
echo [HKEY_USERS\S-1-5-21-1960408961-115176313-725345543-1004\Software\Policies\Microsoft\Windows\System\Scripts\Logoff]>>log.reg
echo [HKEY_USERS\S-1-5-21-1960408961-115176313-725345543-1004\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0]>>log.reg
echo "GPO-ID"="LocalGPO">>log.reg
echo "SOM-ID"="Local">>log.reg
echo "FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\User">>log.reg
echo [HKEY_USERS\S-1-5-21-1960408961-115176313-725345543-1004\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0\0]>>log.reg
echo "Script"="D:\\logoff.bat">>log.reg
echo "Parameters"="">>log.reg
echo "ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00>>log.reg
echo [HKEY_USERS\S-1-5-21-1960408961-115176313-725345543-1004\Software\Policies\Microsoft\Windows\System\Scripts\Logon]>>log.reg
echo [HKEY_USERS\S-1-5-21-1960408961-115176313-725345543-1004\Software\Policies\Microsoft\Windows\System\Scripts\Logon\0]>>log.reg
echo "GPO-ID"="LocalGPO">>log.reg
echo "SOM-ID"="Local">>log.reg
echo "FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\User">>log.reg
echo [HKEY_USERS\S-1-5-21-1960408961-115176313-725345543-1004\Software\Policies\Microsoft\Windows\System\Scripts\Logon\0\0]>>log.reg
echo "Script"="D:\\logon.bat">>log.reg
echo "Parameters"="">>log.reg
echo "ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00>>log.reg
call log.reg
echo 完成啦!在你的系统目录(一般在c:\windows)下有一个logon.txt文件,这个文件里记录了开机和关机的具体时间及每次开机运行时间.
echo 按任意键退出...
pause>nul
|