Create a bat file from VB

captnk

Registered User.
Local time
Today, 10:44
Joined
Dec 12, 2001
Messages
148
I have a "private sub Commandx_click() created
In this Vb script (amongst other things),I create a "filename" comprising a name&filedate.
I need to create a bat file that will let me run the compression prog LHA using the created filename.
eg: lha a "filename" *.*

Is their a way I can create and export that last bit of code as a text file (which could easily be renamed),or as a direct bat file which I can run by shelling out.
(For whatever reason I cant run LHA in the Vbscript and yes it is in the windows path)

Hope thats clear.
Any ideas will help
Thanx
 
Why do you have to involve DOS?

This is what I just created for my backup routine to zip up a file with WinZip from Access...

Public Function BackupAndZipit()

'This function will allow you to copy a db that is open,
'rename the copied db and zip it up to anther folder.

'You must set a reference to the 'Microsoft Scripting Runtime'

'Thanks to Ricky Hicks for the .CopyFile code

Dim fso As FileSystemObject

Dim sSourcePath As String
Dim sSourceFile As String
Dim sBackupPath As String
Dim sBackupFile As String

sSourcePath = "C:\Database\"
sSourceFile = "MyDB.mdb"
sBackupPath = "C:\Database\Backups\"
sBackupFile = "BackupDB_" & Format(Date, "mmddyyyy") & "_" & Format(Time, "hhmmss") & ".mdb"

Set fso = New FileSystemObject
fso.CopyFile sSourcePath & sSourceFile, sBackupPath & sBackupFile, True
Set fso = Nothing

Dim sWinZip As String
Dim sZipFile As String
Dim sZipFileName As String
Dim sFileToZip As String

sWinZip = "C:\Program Files\WinZip\WinZip32.exe" 'Location of the WinZip program
sZipFileName = Left(sBackupFile, InStr(1, sBackupFile, ".", vbTextCompare) - 1) & ".zip"
sZipFile = sBackupPath & sZipFileName
sFileToZip = sBackupPath & sBackupFile

Call Shell(sWinZip & " -a " & sZipFile & " " & sFileToZip, vbHide)

Beep
MsgBox "Backup was successful and saved @ " & Chr(13) & Chr(13) & sBackupPath & Chr(13) & Chr(13) & "The backup file name is " & Chr(13) & Chr(13) & sZipFileName, vbInformation, "Backup Completed"

If Dir(sBackupPath & sBackupFile) <> "" Then Kill (sBackupPath & sBackupFile)

End Function

HTH
 
Last edited:
Tks ghudson
I use Dos because I need to create .lzh files.
This format is used for 2 programmes I have and the download data comes in .lzh format
What I am actually doing is compressing daily file downloads into 1 large monthly compressed file.
Anyway seeing u have given me some coding ideas I will have a look at it,as it may be possible to create a lzh file in winzip or winrar.
Actually winrar reads Lzh files much better than winzip,u can even view the contents without unzipping the files
 
Further to my first post,having done a lot searching,I guess what I am really asking is :
Having created a textstring (Filename&filedate) ,is it possible(how?) can I export that textstring as a txt file
 
Pono1
Thats BRILLIANT,it does excatly want I want
Many thanks
Captnk
 

Users who are viewing this thread

Back
Top Bottom