help with vbs script

Associate
Joined
8 Mar 2007
Posts
2,176
Location
between here and there
hey all,

I've never used vbs but I'm keen to learn. I allready have a very good handel on writing bacth files and have dabbled with vb.net

Could someone please convert the following batch file to vbs, and if possible put a few comments in to explain what does what. (big ask I know!!)

From that I reakon I'll be able to go oin a write a few more!!!


cheers in advance


Code:
@echo off

if exist d:\Graphics\backup.ini (goto next) else goto fin

:next
set /P name=<D:\data\backup.ini
xcopy d:\Graphics \\mpsouth\mpsouth\Marketing\backup\%name% /e /m /c /y /z
goto end


:fin
if exist c:\Graphics\backup.ini (goto next1) else goto end

:next1
set /P name=<C:\Graphics\backup.ini
xcopy C:\Graphics \\mpsouth\mpsouth\Marketing\backup\%name% /e /m /c /y /z
goto end


:end
exit
 
This is a bit of rush job so not tested and no comments, but will hopefully get you started:

Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
If objFSO.FileExists("d:\Graphics\backup.ini") Then
    Set textFile = objFSO.OpenTextFile("d:\Graphics\backup.ini", ForReading)
    Set directoryName = objTextFile.Readline
    Set command = "xcopy d:\Graphics \\mpsouth\mpsouth\Marketing\backup\" & directoryName & "/e /m /c /y /z"
    Set objShell = CreateObject("WScript.Shell")
    Set objScriptExec = objShell.Run command
End If
 
If objFSO.FileExists("c:\Graphics\backup.ini") Then  
    Set textFile = objFSO.OpenTextFile("d:\Graphics\backup.ini", ForReading)
    Set directoryName = objTextFile.Readline
    Set command = "xcopy c:\Graphics \\mpsouth\mpsouth\Marketing\backup\" & directoryName & "/e /m /c /y /z"
    Set objShell = CreateObject("WScript.Shell")
    Set objScriptExec = objShell.Run command
End If

I wasn't sure whether all the paths in your batch example were correct, so you'll need to double check them.
 
Back
Top Bottom