Solved

Simple Batch file to Backup Script ???

Posted on 2002-05-03
2
162 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

724 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