davidpayten
Board Regular
- Joined
- May 24, 2004
- Messages
- 225
Hi All,
Again, thanks for ppl giving me solutions to all the problems I have had so far in the past, this forum has been a godsend.
I have a issue where My vb script executes a .bat file and then outputs a zip file. The problem is is that I need to tell the script to stop while the bat file is running so it can run the rest of the code:
esentially the process,
1) gets a file from a dirctory and drops in a mydirectory
2) it then unzips the file via a bat
3) it then renames the unzipped file into a generic name
ATM I have a seperate 1,2 from 3 for it to work, here is my code so far, at line 36 i have inserted "Wscript.Sleep 1500" but it doesn't appear to stop vb script while it executes a vb script so it can succefully execute 3) above.
Thanks People here is my code so far:
Dim fs, f, f1, fc, s,d
'gets zip bat file - if you change where .bat file is change it here'
Set WshShell = WScript.CreateObject("WScript.Shell")
'WshShell.Run "D:\Scripts\iprevenue scripts\unzipfile.bat"
' gets the postbill file'
Set fs = CreateObject("Scripting.FileSystemObject")
DestinationFolder = "J:\Upload Data\connect\"
folderspec = "G:\BTS\Tech Delivery\general\Development\Business Systems\Mifs\DatabaseWork\mifs_cca_revenue\"
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
If Left(f1.name,11) = "postbillcca" Then
s = left(datevalue(f1.datecreated),10)
If s = left(datevalue(Now()),10) Then
fs.GetFile(f1).copy DestinationFolder
Filename = DestinationFolder & f1.Name
NewFileName = DestinationFolder & "postbillcca.zip"
fs.MoveFile Filename, NewFileName
End if
End if
Next
MsgBox s
'calls zip bat file and extracts the zip file to same directory as where zip file resides'
'will need to change unzip file to the server directory'
WshShell.Run "D:\Scripts\iprevenueScripts\unzipfile.bat"
'script.WshShell.Wait [1500]'
Wscript.Sleep 1500
'Rename unziped file to generic file so access can pickup file'
folderspec = "J:\Upload Data\connect\"
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
If Instr(1,f1.name,"postbillcca") > 0 AND right(f1.name,3) = "txt" Then
fs.GetFile(f1).copy folderspec
Filename = folderspec & f1.Name
NewFileName = folderspec & "postbillcca.txt"
fs.MoveFile Filename, NewFileName
End if
Next
Again, thanks for ppl giving me solutions to all the problems I have had so far in the past, this forum has been a godsend.
I have a issue where My vb script executes a .bat file and then outputs a zip file. The problem is is that I need to tell the script to stop while the bat file is running so it can run the rest of the code:
esentially the process,
1) gets a file from a dirctory and drops in a mydirectory
2) it then unzips the file via a bat
3) it then renames the unzipped file into a generic name
ATM I have a seperate 1,2 from 3 for it to work, here is my code so far, at line 36 i have inserted "Wscript.Sleep 1500" but it doesn't appear to stop vb script while it executes a vb script so it can succefully execute 3) above.
Thanks People here is my code so far:
Dim fs, f, f1, fc, s,d
'gets zip bat file - if you change where .bat file is change it here'
Set WshShell = WScript.CreateObject("WScript.Shell")
'WshShell.Run "D:\Scripts\iprevenue scripts\unzipfile.bat"
' gets the postbill file'
Set fs = CreateObject("Scripting.FileSystemObject")
DestinationFolder = "J:\Upload Data\connect\"
folderspec = "G:\BTS\Tech Delivery\general\Development\Business Systems\Mifs\DatabaseWork\mifs_cca_revenue\"
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
If Left(f1.name,11) = "postbillcca" Then
s = left(datevalue(f1.datecreated),10)
If s = left(datevalue(Now()),10) Then
fs.GetFile(f1).copy DestinationFolder
Filename = DestinationFolder & f1.Name
NewFileName = DestinationFolder & "postbillcca.zip"
fs.MoveFile Filename, NewFileName
End if
End if
Next
MsgBox s
'calls zip bat file and extracts the zip file to same directory as where zip file resides'
'will need to change unzip file to the server directory'
WshShell.Run "D:\Scripts\iprevenueScripts\unzipfile.bat"
'script.WshShell.Wait [1500]'
Wscript.Sleep 1500
'Rename unziped file to generic file so access can pickup file'
folderspec = "J:\Upload Data\connect\"
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
If Instr(1,f1.name,"postbillcca") > 0 AND right(f1.name,3) = "txt" Then
fs.GetFile(f1).copy folderspec
Filename = folderspec & f1.Name
NewFileName = folderspec & "postbillcca.txt"
fs.MoveFile Filename, NewFileName
End if
Next