Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Simple Batch file to Backup Script ???

Posted on 2002-05-03
2
Medium Priority
?
166 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 300 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

609 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