@ECHO OFF
ECHO any comments suggestions are welcome at :
ECHO http://ysgitdiary.blogspot.com/search/label/Putty
ECHO This batch file copies some the needed settings of Putty
ECHO it depends on a simple GetNiceTime_on_%computername%.cmd
ECHO batch file producing the %_NICETIME% variable in YYYYMMDD_hhmmss
ECHO format
ECHO Tested on Win7 64 -bit Putty
ECHO you should call this batch file from its current directorry
:: GET A YYYYMMDD_hhmmss TIMESTAMP
call GetNiceTime_on_%computername%.cmd
SET _RegFileWithSettings=PuttySettings_Helios_on_%COMPUTERNAME%_%NiceTime%.reg
SET _RunLog=%0.run.log
SET _ErrorLog=%0.error.log
::SET _PuttySynFilesDirOnWin64=%ProgramFiles(x86)%\Putty 5\system
::SET _PortableSynFilesDir=%CD%\system
SET _RegistryKey=HKEY_CURRENT_USER\Software\SimonTatham
SET _RegistryFilesDir=%CD%\reg
SET _RegistryFileWithSettings=%_RegistryFilesDir%\PuttySettings_on_%computername%_%NiceTime%.reg
SET _LogDir="%CD%\log"
ECHO START REGISTRY SETTINGS EXPORT AT %_NiceTime%
ECHO RUN LOG : START REGISTRY SETTINGS EXPORT AT %_NiceTime% >%_RunLog%
ECHO ERROR LOG START REGISTRY SETTINGS EXPORT AT %_NiceTime% >%_ErrorLog%
ECHO.1>>%_RunLog% 2>> %_ErrorLog%
ECHO create a directory called sysm in the current directory
ECHO create a directory called sysm in the current directory 1>>%_RunLog% 2>> %_ErrorLog%
ECHO.1>>%_RunLog% 2>> %_ErrorLog%
ECHO now copy alls the files from the %Program Files(x86)%\Putty 5\system\
ECHO now copy alls the files from the %Program Files(x86)%\Putty 5\system\ 1>>%_RunLog% 2>> %_ErrorLog%
ECHO IF NOT EXIST %_PortableSynFilesDir% MKDIR %_PortableSynFilesDir% 1>>%_RunLog% 2>> %_ErrorLog%
:: IF NOT EXIST %_PortableSynFilesDir% MKDIR %_PortableSynFilesDir% 1>>%_RunLog% 2>> %_ErrorLog%
ECHO.1>>%_RunLog% 2>> %_ErrorLog%
ECHO COPY EACH syn files
:: for /f "tokens=*" %%i in (' dir "%_PuttySynFilesDirOnWin64%\*.syn" /s /b') do copy /y "%%i" "%_PortableSynFilesDir%" 1>>%_RunLog% 2>> %_ErrorLog%
ECHO.1>>%_RunLog% 2>> %_ErrorLog%
:: CREATE THE _RegistryFilesDir if it does not exist
ECHO IF NOT EXIST %_RegistryFilesDir% MKDIR %_RegistryFilesDir% 1>>%_RunLog% 2>> %_ErrorLog%
IF NOT EXIST %_RegistryFilesDir% MKDIR %_RegistryFilesDir% 1>>%_RunLog% 2>> %_ErrorLog%
ECHO.1>>%_RunLog% 2>> %_ErrorLog%
:: NOW PERFORM THE ACTUAL EXPORT OF THE CURRENT SETTINGS
ECHO REG EXPORT "%_RegistryKey%" "%_RegistryFileWithSettings%" 1>>%_RunLog% 2>> %_ErrorLog%
REG EXPORT "%_RegistryKey%" "%_RegistryFileWithSettings%"
ECHO IF NOT EXIST %_LogDir% MKDIR %_LogDir% 1>>%_RunLog% 2>> %_ErrorLog%
IF NOT EXIST %_LogDir% MKDIR %_LogDir% 1>>%_RunLog% 2>> %_ErrorLog%
ECHO.1>>%_RunLog% 2>> %_ErrorLog%
ECHO COPY THE LOG FILES TO THE LOG DIRECTOREY FIRST
FOR /F %%i in ('dir "%CD%\*.log" /b') do copy /y "%%i" "%_LogDir%\"
:: DEBUG PAUSE
:: wait for 3 seconds
ping localhost -n 3
ECHO DONE NOW OPEN THE LOG FILES TO SEE THE RESULTS :
:: if you donät have textpad FOR /F %%i in ('dir "%CD%\log\*.log" /s /b') do cmd /c start /max notepad "%%i"
FOR /F %%i in ('dir "%_LogDir%\*.log" /s /b') do cmd /c start /max textpad "%%i"
ECHO NOW DELETE THE ALREADY COPIED LOG FILES FROM THE CURRENT DIR
FOR /F %%i in ('dir "%CD%\*.log" /b') do del /q "%%i"
:: NOW OPEN TO VIEW THE REGISTRY FILE AS WELL
:: CMD /C START /MAX notepad %_RegistryFileWithSettings%
CMD /C START /MAX textpad %_RegistryFileWithSettings%
:: HINT: you could execute any dos file including this one by creating a new external tool
:: Command: cmd.exe , Parameters: CMD /C $FileName , Check Prompt for parameters
:: Check Save all documents first , Check Capture output , Check Suppress output untill completed
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!