-
hi all
I need my program to automatically back the database up every month
I mad a small backup.bat file in DOS whcih just copies my database to a disk
it is
copy c:\crms.mdb a:\
then in vb i try to execute it by...
dim x
x = shell("c:\backup.bat")
but nothing happens.
is there a way to execute this batch file from VB.
Or does anyone know the better way of doing it...i.e.copying the file to disk straight via VB. I am not sure of those file.copy etc commands
thanks in advance
-
use windows schedular
i just made a automation bot that copies refreshes information from one table to another every night at 3 am
and i have this set up with windows scheduler so that it runs at 3 am without me touching a thing
when its done
it shuts itself down..
-
I have an app that creates a .bat file and executes it. I use ShellExecute.
Code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As _
String, ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
Here is the function that writes and executes the .bat file.
Code:
Function Run_Download(cmdline As String) As Long
' Build batch file to run the download
Dim curr_drive As Variant
Dim curr_path As Variant
Dim batfile As String
' Get current path
curr_path = CurDir
curr_drive = Left$(curr_path, 2)
' open batch file
batfile = App.Path & "\wftu.bat"
Open batfile For Output As #giFileNum
' and write the commands
Print #giFileNum, gsPCDrive(giPCPath)
Print #giFileNum, "cd " & gsPCPath(giPCPath)
If Left$(cmdline, 10) = gsPCEXE(giPCPath) Then
Print #giFileNum, cmdline
Else
Print #giFileNum, "call " & cmdline
End If
Print #giFileNum, "rem "
Print #giFileNum, "pause"
Print #giFileNum, curr_drive
Print #giFileNum, "cd " & curr_path
If Exists(gsINIFile) Then
Print #giFileNum, "del " & gsINIFile
End If
Print #giFileNum, "del " & batfile
Close #giFileNum
Run_Download = ShellExecute(gScr_hDC, "Open", batfile, _
"", "C:\", gSW_SHOWNORMAL)
End Function
-
Try
x = shell("<path to>\cmd.exe c:\backup.bat")