本文主要是介绍备份文件时,添加时间戳,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
备份文件时,添加时间戳
BackFileTool.bat
=====================
@echo off
set BACK_FROM=%1
set BACK_TO=%2
move %BACK_FROM% %BACK_TO%.BAK[%date:~0,4%%date:~5,2%%date:~8,2%.%time:~0,2%%time:~3,2%%time:~6,2%].xlsx
=====================
VBA代码
Public Sub backupOupputFile()On Error GoTo errl'■バッチ対象Dim BAT_BACKUP_TOOL As String: BAT_BACKUP_TOOL = BAT_FILE_URL & "\" & BAT_BACKUP_TOOL_FILE_NAMEIf BAK_FILE_EXIST_FLG = "1" ThenDim BACK_FROM As String: BACK_FROM = BACK_FROM & BACK_FILE_NAMEDim BACK_TO As String: BACK_TO_TMS = BACK_TO & BACK_FILE_NAME'bat命令Dim cmdStrcmdStr = """" & BAT_BACKUP_TOOL & """" & " " & """" _& BACK_FROM & """" & " " & """" & BACK_TO & """"'MsgBox cmdStr'バッチを実行するRetVal = Shell(cmdStr)processId2 = OpenProcess(&H100000, False, RetVal)r2 = WaitForSingleObject(processId2, -1&)r2 = CloseHandle(processId2)End IfGoTo endokerrl:'異常処理ERROR_FLG = "1"ERROR_INFO_LIST.Add ("関数:「backupOupputFile」で、エラー発生しました。")ERROR_INFO_LIST.Add ("エラー詳細:" & Err.Number & " : " & Err.Description)endok:End Sub
http://blog.csdn.net/sxzlc/article/details/73752002
这篇关于备份文件时,添加时间戳的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!