0
我新的這一點,我想獲得一個VBScript(因爲aplicattion只能用這個作品)塔,使幾個目錄和文件的備份備份文件夾...創建幾個目錄和文件
例子:
Check if Folder1 exist... (It may be on c:\ or another drive)
If don´t exist the finish
If exist than should create a Bck Folder
THan Backup the folders that are inside folder1 (Folder2, Folder3)
Also backup all the files that are *.mds, *.vbs inside Folder4
The script have to maintain the struture...
And after that delete all folder1
這是我到目前爲止有:
IF NOT EXIST "%INSTALLDIR%\Folder1\" GOTO ENDPROG
mkdir "%INSTALLDIR%\BCK\"
mkdir "%INSTALLDIR%\BCK\DADOS\"
mkdir "%INSTALLDIR%\BCK\IMAGEM\"
mkdir "%INSTALLDIR%\BCK\CONFIG\"
mkdir "%INSTALLDIR%\BCK\OFFBck"
copy "%INSTALLDIR%\Folder1\Dados*.MDB" "%INSTALLDIR%\BCK\dados\"
copy "%INSTALLDIR%\Folder1\Dados*.MDD" "%INSTALLDIR%\BCK\dados\"
copy "%INSTALLDIR%\Folder1\Dados*.VEI" "%INSTALLDIR%\BCK\dados\"
copy "%INSTALLDIR%\Folder1\Imagem*.*" "%INSTALLDIR%\BCK\Imagem\"
copy "%INSTALLDIR%\Folder1*.cfg" "%INSTALLDIR%\BCK\Config\"
copy "%INSTALLDIR%\Folder1\OFFbck*.ZIP" "%INSTALLDIR%\BCK\OFFbck\"
copy "%INSTALLDIR%\Folder1\Folder1\OFFbck*.ZIP" "%INSTALLDIR%\BCK\OFFbck\"
rmdir "%INSTALLDIR%\Folder1" /s /q
:ENDPROG
誰能給我一個手呢?
我已經做這個.....但我給一個錯誤,如果該文件夾已經存在備份....但我不能開始複製....
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists("C:\Folder1") Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const OverwriteExisting = TRUE
Set objFolder = objFSO.CreateFolder("C:\BCK")
Set objFolder = objFSO.CreateFolder("C:\BCK\Imagem")
Set objFolder = objFSO.CreateFolder("C:\BCK\dados")
Set objFolder = objFSO.CreateFolder("C:\BCK\config")
Set objFolder = objFSO.CreateFolder("C:\BCK\off")
Else
End If
在此先感謝
我剛剛創建這個....
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists("C:\audatex") Then
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder("C:\BCK")
Set objFolder = objFSO.CreateFolder("C:\BCK\Imagem")
Set objFolder = objFSO.CreateFolder("C:\BCK\dados")
Set objFolder = objFSO.CreateFolder("C:\BCK\WTB")
Set objFolder = objFSO.CreateFolder("C:\BCK\CFG")
Set objFolder = objFSO.CreateFolder("C:\BCK\config")
Set objFolder = objFSO.CreateFolder("C:\BCK\offdaten")
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Audatex\offdaten\*.zip" , "c:\BCK\Offdaten\" , OverwriteExisting
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Audatex\Dados\*.vei" , "c:\BCK\dados\" , OverwriteExisting
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Audatex\Dados\*.mdd" , "c:\BCK\dados\" , OverwriteExisting
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Audatex\*.cfg" , "c:\BCK\CFG\" , OverwriteExisting
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Audatex\Dados\*.mdb" , "c:\BCK\dados\" , OverwriteExisting
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "C:\Audatex\Imagem" , "c:\BCK\Imagem" , OverwriteExisting
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Audatex\WTB\*.wtb" , "c:\BCK\WTB\" , OverwriteExisting
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Audatex\WTB\*.dtb" , "c:\BCK\WTB\" , OverwriteExisting
End IF
但是知道我有以下問題:如果有什麼關於我得到一個錯誤的文件夾,我不能覆蓋文件夾
感謝
我試過了,我做了一個vbscritp來調用一個批處理,但我需要在vbscript裏面有一切......我不懂vbscript語言......這是一個簡單的工作安裝 – user2696076
向我們展示您嘗試過的內容,然後我們可以幫助您完成工作。 – aphoria
請不要在評論中發佈代碼。改爲編輯你的問題。此外,你有什麼是批處理代碼,而不是VBScript代碼。在VBScript中封裝批處理代碼是可能的(使用['Run'](http://msdn.microsoft.com/en-us/library/d5fk67ky%28v=vs.84%29.aspx)或['Exec'] (http://msdn.microsoft.com/en-us/library/ateytk4a%28v=vs.84%29.aspx)方法),但我不會爲您描述的任務提供建議。要麼使用批處理,要麼用適當的VBScript重新實現它。 –