Solved

Simple Batch file to Backup Script ???

Posted on 2002-05-03
2
160 Views
Last Modified: 2010-05-02
I have written a simple batch to backup files to a server ...  Now I know nothing about VB, but do know there is so much more you can do with it.  Can anyone help me out ??

cd c:\My Documents
echo %username% was last backed up %time% %date% > Date.txt
xcopy *.* \\Pongo\Home\%Username% /I /E /V /H /R /D /Y

Now I need to tart it up a little.  I need the following :

1. It to run in a Window so the user can see what it is doing / copying

2. Some sort of interaction from the user ie: You are about to back up your data to the server do you wish to continue ?

3. A completion statement ie: Your data has been backed up to \\location press any key to exit.

Thanks in Advance
0
Comment
Question by:rhodrih
2 Comments
 
LVL 15

Expert Comment

by:cquinn
ID: 6988284
Why not just use the Microsoft Backup program - it does all this for you
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 100 total points
ID: 6988514
you could try something like this

Option Explicit
Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "Kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Const STILL_ACTIVE = &H103
Const PROCESS_QUERY_INFORMATION = &H400

Private Sub Shell32Bit(ByVal JobToDo As String)
Dim hProcess As Long
Dim RetVal As Long
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(JobToDo, 1))
Do
    GetExitCodeProcess hProcess, RetVal
    DoEvents: Sleep 100
Loop While RetVal = STILL_ACTIVE
End Sub

Private Sub Command1_Click()
Dim rsp As String
Dim strSh As String
Dim strUser As String
Dim nLen As Long
strUser = Space(256)
nLen = 256
Call GetUserName(strUser, nLen)
strUser = Left$(strUser, nLen - 1)
rsp = MsgBox("Would you like to backup all of your files now?", vbYesNoCancel, "Backup Files?")
If rsp = vbYes Then
    strSh = "command.com /c xcopy C:\*.* \\Pongo\Home\" & strUser & " /h/i/c/k/e/r"
    Shell32Bit strSh
    GoTo zDone
End If
MsgBox "Operation Cancelled!"
Exit Sub
zDone:
MsgBox "Data has been backed up to \\Pongo\Home\" & strUser & ".Press Ok to Exit"
End Sub
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question