VBA Make Access wait API is not working

R

rebelscum0000

Dear All

The API: Shell and Wait, by Terry Kreft is not working to me

http://www.mvps.org/access/api/api0004.htm

I know I can not post the API by Terry Kreft, but I can post what
changes I did in the original API
------
Function ShellWait(Pathname As String, Optional WindowStyle As Long)
End Function
-----

This is my code in a module

'Initialize New Event Make_Access_Wait
'Make Access wait till It is done with other application
MsgBox "Rutina ShellWait"
Call ShellWait("C:\Program Files\Dups\Batch Files\HashIt.bat")

I really need to Access wait till I'm done with my other application.
But due is not working I had to add another API

API: Make code go to Sleep by by Dev Ashish

http://www.mvps.org/access/api/api0021.htm


'Implement a wait period in Access where the duration can be
'increased/decreased bychanging the constant to a corressponding
higher/lower value
MsgBox "Rutina sSleep"
Call sSleep(9000)

This API is working fine, the problem is the code does a hash in
different directories, some of them with a lot of files to hash,
others with a few

In this way if the user selects a directory with few files to hash the
user has to wait 9000 milliseconds. In other hands if the user selects
a directory with a lot of files also he has to wait the same time, but
some directories could take more than 1 hour to complete the entire
process

I don not want to use the API: Make code go to Sleep by Dev Ashish for
this reason, and I do know what I its wrong with the API by Terry
Kreft or why is not working for my code

I first want to know why the API by Terry Kreft is not working for me,
and if there is another alternative to make Access wait till the
entire process ends.
Thanks in advance for any help
Regards,
Antonio Macias
 
D

Douglas J. Steele

What's the code in your batch file? If your batch file is, say, firing off
other batch files, the API won't know anything about them.
 
R

rebelscum0000

Hi Douglas, good to read you as always
What's the code in your batch file?

My batch file contains

CD /D "C:\Program Files\CDCheck"
START /WAIT CDCheck /CRC:MD5 "C:\Downloads" /O:"C:\Downloads
\Downloads.CRC" /SaveReport:"C:\Downloads\Downloads Report.txt"

The codes create a MS-DOS Batch File:
'Writing out a batch file (.bat or .vbs) using VBA
I Call this file called HashIt.bat
If I does not make Access wait to finish the task of the .bat file,
the results are; incomplete file .CRC and Report.txt and executing the
next VBA statement.

Please help
Thanks in advance
Regards,
Antonio Macias

My entire code is

Sub OpenWinBrowse()
Dim MyDlg As New DialogClass 'Common Dialogs Class Module for Access
and VBA
Dim vArr As Variant
Dim MyDigResponse As Integer
Dim j As Integer
Dim itemCount As Integer
Dim MyCodeSelection As Integer
Dim GetFolder As String
Dim strDrive As String
Dim FirstFolder As String
Dim LastFolder As String
Dim strItems As String
Dim TempCRCFile As String
Dim TempTXTFile As String
Dim strDir As String
Dim strVerify As String
Dim newDirectory As String
Dim ccgFF As Integer
Dim egfFF As Integer
Dim amcFF As Integer

'References:
'Microsoft DA0 3.6 Object Runtime

'Opens the Browse Dialog
With MyDlg
.TypeFile = 0 'All file Types
.TypeFile = 4 'Text Files
.DialogType = "Browse"
End With

'Show the select type of dialog selected with the properties
desired
MyDlg.Show

'Waits for the user to click a button, and returns an Integer
indicating which button
'the user clicked .DialogType = "Browse"
MyDigResponse = Len(MyDlg.ReturnFilePath)

If MyDigResponse = 0 Then
'User chose Cancel.
MsgBox "User Cancelled", vbExclamation, "Browse"
End
Else
'User Chose OK.
End If

'The name for the chosen file or directory
'Drive>:\ OR <Drive>:\Folder OR <Drive>:\Folder\Folder..
GetFolder = MyDlg.ReturnFilePath
Debug.Print "GetFolder = " & GetFolder

'Initialize New Event Split_GetFolder
'Splits The Folders in GetFolder
'Initialize Variables
vArr = Split(GetFolder, "\")

For j = 0 To UBound(vArr)
'Folders in the string separated by { \ }
If Len(vArr(j)) > 0 Then
strItems = strItems & vArr(j) & vbCr
'Debug.Print strItems
itemCount = itemCount + 1
End If
Next

Debug.Print "there are " & itemCount & " Items in this string" &
vbCr & strItems

'Manage Drive and Folders OF GetFolder
'<Drive>
strDrive = Left(vArr(0), 1)
Debug.Print "Drive = " & strDrive
'First Folder
FirstFolder = vArr(1)
Debug.Print "First Folder = " & FirstFolder
'Last Folder
LastFolder = vArr(itemCount - 1)
Debug.Print "Last Folder = " & LastFolder

'Start Event Selection_Drive_Folders
'Determine IF is <Drive>:\ OR <Drive>:\Folder OR <Drive>:\Folder
\Folder...
If itemCount = 1 Then

Debug.Print "Is <Drive>:\"
MyCodeSelection = 1
TempCRCFile = GetFolder & strDrive & " Temp" & ".CRC"
TempTXTFile = GetFolder & strDrive & " Report" & ".txt"
strDir = GetFolder & strDrive & ".CRC" 'Esto para que era?
strVerify = GetFolder & strDrive & " Verification" & ".txt"
'Esto para que era?

ElseIf itemCount = 2 Then

Debug.Print "IS <Drive>:\Folder"
MyCodeSelection = 2
TempCRCFile = GetFolder & "\" & FirstFolder & " Temp" & ".CRC"
TempTXTFile = GetFolder & "\" & FirstFolder & " Report" &
".txt"
strDir = GetFolder & "\" & FirstFolder & ".CRC" 'Esto para que
era?
strVerify = GetFolder & "\" & FirstFolder & " Verification" &
".txt" 'Esto para que era?

ElseIf itemCount >= 3 Then

Debug.Print "IS <Drive>:\Folder\Folder..."
MyCodeSelection = 3
TempCRCFile = GetFolder & "\" & strDrive & " " & FirstFolder &
" TO " & LastFolder & " Temp" & ".CRC"
TempTXTFile = GetFolder & "\" & strDrive & " " & FirstFolder &
" TO " & LastFolder & " Report" & ".txt"
strDir = GetFolder & "\" & strDrive & " " & FirstFolder & " TO
" & LastFolder & ".CRC" 'Esto para que era?
strVerify = GetFolder & "\" & strDrive & " " & FirstFolder & "
TO " & LastFolder & " Verification" & ".txt" 'Esto para que era?
Debug.Print strVerify

End If

Debug.Print "MyCodeSelection = " & MyCodeSelection

'Initialize New Event API_File_Exists
'API FileExists: Returns True of False If a File Exists
'IF FileExists = True Then Kill

If FileExists(TempCRCFile) = True Then
Debug.Print "File Exists: = True"
'<Drive>:\<Drive> Temp.CRC OR
'<Drive>\Folder\FirstFolder Temp.CRC OR
'<Drive>:\Folder\Folder...\<Drive> FirstFolder TO LastFolder
Temp.CRC
Kill (TempCRCFile)
Else
Debug.Print "File Exists: = False"
End If

If FileExists(TempTXTFile) = True Then
Debug.Print "File Exists: = True"
'<Drive>:\<Drive> Report.txt OR
'<Drive>\Folder\FirstFolder Report.txt OR
'<Drive>:\Folder\Folder...\<Drive> FirstFolder TO
LastFolder Report.txt
Kill (TempTXTFile)
Else
Debug.Print "File Exists: = False"
End If

If FileExists(strVerify) = True Then
Debug.Print "File Exists: = True"
'<Drive>:\<Drive> Report.txt OR
'<Drive>\Folder\FirstFolder Report.txt OR
'<Drive>:\Folder\Folder...\<Drive> FirstFolder TO
LastFolder Report.txt
Kill (strVerify)
Else
Debug.Print "File Exists: = False"
End If

If FileExists("C:\Program Files\Dups\Batch Files\HashIt.bat") =
True Then
Debug.Print "Batch File Exists: = True"
Kill ("C:\Program Files\Dups\Batch Files\HashIt.bat")
Else
Debug.Print "Batch File Exists: = False"
End If

'Initialize New Event Writing_out_Temporal_CRC_File
'Initialize Variables

ccgFF = FreeFile()

'Writing out a Temporal .CRC file:
'<Drive>:\<Drive> Temp.CRC OR
'<Drive>\Folder\FirstFolder Temp.CRC OR
'<Drive>:\Folder\Folder...\<Drive> FirstFolder TO LastFolder
Temp.CRC
'In order to add this file into the Hash File without user
intervention (Writing out a Temporal batch file)

Open TempCRCFile For Output As #ccgFF
Close #ccgFF ' Close file

'Initialize New Event Writing_out_Temporal_Report_TXT_File
'Initialize Variables

egfFF = FreeFile()

'Writing out a Temporal Report TXT file:
'<Drive>:\<Drive> Report.txt OR
'<Drive>\Folder\FirstFolder Report.txt OR
'<Drive>:\Folder\Folder...\<Drive> FirstFolder TO LastFolder
Report.txt
'In order to add this file into the Hash File without user
intervention (Writing out a Temporal batch file)

Open TempTXTFile For Output As #egfFF
Print #egfFF, "============ 00/00/0000 00:00:00 AM/PM
============"
Print #egfFF, "-- Results --"
Print #egfFF, "Info"
Print #egfFF, "- date: 00/00/0000"
Print #egfFF, "- process: Hash"
Print #egfFF, "- source: <Drive>:\<Folder>"
Print #egfFF, "- source volume label: Volume Name"
Print #egfFF, ' Write blank line.
Print #egfFF, "Basic statistics"
Print #egfFF, "- time elapsed: 00:00:00"
Print #egfFF, "- overall transfer [kB/s]:
000000000000,000000000000"
Print #egfFF, "- folders processed: 000000000000"
Print #egfFF, "- files processed: 00000000000000"
Print #egfFF, "- source bytes read: 000000000000 MB
(000000000000,000000000000,000000000000 bytes)"
Print #egfFF, "- source average transfer [kB/s]:
000000000000,000000000000"
Print #egfFF, "- source clean transfer [kB/s]:
000000000000,000000000000"
Print #egfFF, ' Write blank line.
Print #egfFF, "Errors"
Print #egfFF, "- errors: 000000000000"
Print #egfFF, "- warnings: 0000000000"
Print #egfFF, "- other: 0000000000000"
Print #egfFF, ' Write blank line.
Print #egfFF, "-- Messages --"
Print #egfFF, "note;hash;Hash file created (code:
0000000000000);<Drive>:\<Folder>:\File.CRC"
Print #egfFF, "note;hash;Hash file created (code:
0000000000000);<Drive>:\<Folder>:\File.CRC"
Print #egfFF, "note;hash;Hash file created (code:
0000000000000);<Drive>:\<Folder>:\File.CRC"
Close #egfFF ' Close file.

'Initialize New Event
API_Folder_Exists_And_CreateDirectory_Nested_Folders
'API Folder Exists
'Checks IF the Folder exists, IF NOT THEN create it
If FolderExists("C:\Program Files\Dups\Batch Files") = True Then
'Folder exists
Debug.Print "Folder Exists"
Else
'API CreateDirectory Nested Folders
'Folder does not exist
MsgBox "Folder Does not exits"
newDirectory = "C:\Program Files\Dups\Batch Files"
CreateNestedFoldersByPath (newDirectory)
Debug.Print "Folder Does not Exists"
End If

'Initialize New Event Writing_out_batch_file_CDCheck
'Initialize Variables

amcFF = FreeFile()

'Writing out a batch file (.bat or .vbs) using VBA
'Working and Tested Solution
'Determine IF is <Drive>:\ OR <Drive>:\Folder OR <Drive>:\Folder
\Folder...
'Please note: Very Sensitive if the user opens a file the hash
change
If MyCodeSelection = 1 Then

Open "C:\Program Files\Dups\Batch Files\HashIt.bat" For
Output As #amcFF
Print #amcFF, "CD /D " & Chr(34) & Environ("ProgramFiles")
& "\CDCheck" & Chr(34)
Print #amcFF, "START /WAIT CDCheck /CRC:MD5 " & Chr(34) &
GetFolder & Chr(34) & Chr(32) & _
"/O:" & Chr(34) & GetFolder & strDrive & ".CRC" & Chr(34)
& Chr(32) & _
"/SaveReport:" & Chr(34) & GetFolder & strDrive & "
Report" & ".txt" & Chr(34)
Close #amcFF

ElseIf MyCodeSelection = 2 Then

Open "C:\Program Files\Dups\Batch Files\HashIt.bat" For Output
As #amcFF
Print #amcFF, "CD /D " & Chr(34) & Environ("ProgramFiles")
& "\CDCheck" & Chr(34)
Print #amcFF, "START /WAIT CDCheck /CRC:MD5 " & Chr(34) &
GetFolder & Chr(34) & Chr(32) & _
"/O:" & Chr(34) & GetFolder & "\" & FirstFolder & ".CRC" &
Chr(34) & Chr(32) & _
"/SaveReport:" & Chr(34) & GetFolder & "\" & FirstFolder &
" Report" & ".txt" & Chr(34)
Close #amcFF

ElseIf MyCodeSelection = 3 Then

Open "C:\Program Files\Dups\Batch Files\HashIt.bat" For Output
As #amcFF
Print #amcFF, "CD /D " & Chr(34) & Environ("ProgramFiles")
& "\CDCheck" & Chr(34)
Print #amcFF, "START /WAIT CDCheck /CRC:MD5 " & Chr(34) &
GetFolder & Chr(34) & Chr(32) & _
"/O:" & Chr(34) & GetFolder & "\" & strDrive & " " &
FirstFolder & " TO " & LastFolder & _
".CRC" & Chr(34) & Chr(32) & _
"/SaveReport:" & Chr(34) & GetFolder & "\" & strDrive & "
" & FirstFolder & " TO " & _
LastFolder & " Report" & ".txt" & Chr(34)
Close #amcFF

End If

Debug.Print "MyCodeSelection = " & MyCodeSelection

MsgBox "Termine el Hash"

'Initialize New Event Make_Access_Wait
'Make Access wait till It is done with other application
MsgBox "Rutina ShellWait"
Call ShellWait("C:\Program Files\Dups\Batch Files\HashIt.bat")
'Implement a wait period in Access where the duration can be
'increased/decreased bychanging the constant to a corressponding
higher/lower value
MsgBox "Rutina sSleep"
Call sSleep(9000)

Next VBA statment <----

End Sub
 
D

Douglas J. Steele

See what happens if you use

Dim strStatement As String

strStatement = """C:\Program Files\CDCheckCDCheck"" /CRC:MD5 " & _
"""C:\Downloads"" /O:""C:\Downloads\Downloads.CRC"" " & _
" /SaveReport:""C:\Downloads\Downloads Report.txt"""

Call ShellWait(strStatement)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


rebelscum0000 said:
Hi Douglas, good to read you as always
What's the code in your batch file?

My batch file contains

CD /D "C:\Program Files\CDCheck"
START /WAIT CDCheck /CRC:MD5 "C:\Downloads" /O:"C:\Downloads
\Downloads.CRC" /SaveReport:"C:\Downloads\Downloads Report.txt"

The codes create a MS-DOS Batch File:
'Writing out a batch file (.bat or .vbs) using VBA
I Call this file called HashIt.bat
If I does not make Access wait to finish the task of the .bat file,
the results are; incomplete file .CRC and Report.txt and executing the
next VBA statement.

Please help
Thanks in advance
Regards,
Antonio Macias

My entire code is

Sub OpenWinBrowse()
Dim MyDlg As New DialogClass 'Common Dialogs Class Module for Access
and VBA
Dim vArr As Variant
Dim MyDigResponse As Integer
Dim j As Integer
Dim itemCount As Integer
Dim MyCodeSelection As Integer
Dim GetFolder As String
Dim strDrive As String
Dim FirstFolder As String
Dim LastFolder As String
Dim strItems As String
Dim TempCRCFile As String
Dim TempTXTFile As String
Dim strDir As String
Dim strVerify As String
Dim newDirectory As String
Dim ccgFF As Integer
Dim egfFF As Integer
Dim amcFF As Integer

'References:
'Microsoft DA0 3.6 Object Runtime

'Opens the Browse Dialog
With MyDlg
.TypeFile = 0 'All file Types
.TypeFile = 4 'Text Files
.DialogType = "Browse"
End With

'Show the select type of dialog selected with the properties
desired
MyDlg.Show

'Waits for the user to click a button, and returns an Integer
indicating which button
'the user clicked .DialogType = "Browse"
MyDigResponse = Len(MyDlg.ReturnFilePath)

If MyDigResponse = 0 Then
'User chose Cancel.
MsgBox "User Cancelled", vbExclamation, "Browse"
End
Else
'User Chose OK.
End If

'The name for the chosen file or directory
'Drive>:\ OR <Drive>:\Folder OR <Drive>:\Folder\Folder..
GetFolder = MyDlg.ReturnFilePath
Debug.Print "GetFolder = " & GetFolder

'Initialize New Event Split_GetFolder
'Splits The Folders in GetFolder
'Initialize Variables
vArr = Split(GetFolder, "\")

For j = 0 To UBound(vArr)
'Folders in the string separated by { \ }
If Len(vArr(j)) > 0 Then
strItems = strItems & vArr(j) & vbCr
'Debug.Print strItems
itemCount = itemCount + 1
End If
Next

Debug.Print "there are " & itemCount & " Items in this string" &
vbCr & strItems

'Manage Drive and Folders OF GetFolder
'<Drive>
strDrive = Left(vArr(0), 1)
Debug.Print "Drive = " & strDrive
'First Folder
FirstFolder = vArr(1)
Debug.Print "First Folder = " & FirstFolder
'Last Folder
LastFolder = vArr(itemCount - 1)
Debug.Print "Last Folder = " & LastFolder

'Start Event Selection_Drive_Folders
'Determine IF is <Drive>:\ OR <Drive>:\Folder OR <Drive>:\Folder
\Folder...
If itemCount = 1 Then

Debug.Print "Is <Drive>:\"
MyCodeSelection = 1
TempCRCFile = GetFolder & strDrive & " Temp" & ".CRC"
TempTXTFile = GetFolder & strDrive & " Report" & ".txt"
strDir = GetFolder & strDrive & ".CRC" 'Esto para que era?
strVerify = GetFolder & strDrive & " Verification" & ".txt"
'Esto para que era?

ElseIf itemCount = 2 Then

Debug.Print "IS <Drive>:\Folder"
MyCodeSelection = 2
TempCRCFile = GetFolder & "\" & FirstFolder & " Temp" & ".CRC"
TempTXTFile = GetFolder & "\" & FirstFolder & " Report" &
".txt"
strDir = GetFolder & "\" & FirstFolder & ".CRC" 'Esto para que
era?
strVerify = GetFolder & "\" & FirstFolder & " Verification" &
".txt" 'Esto para que era?

ElseIf itemCount >= 3 Then

Debug.Print "IS <Drive>:\Folder\Folder..."
MyCodeSelection = 3
TempCRCFile = GetFolder & "\" & strDrive & " " & FirstFolder &
" TO " & LastFolder & " Temp" & ".CRC"
TempTXTFile = GetFolder & "\" & strDrive & " " & FirstFolder &
" TO " & LastFolder & " Report" & ".txt"
strDir = GetFolder & "\" & strDrive & " " & FirstFolder & " TO
" & LastFolder & ".CRC" 'Esto para que era?
strVerify = GetFolder & "\" & strDrive & " " & FirstFolder & "
TO " & LastFolder & " Verification" & ".txt" 'Esto para que era?
Debug.Print strVerify

End If

Debug.Print "MyCodeSelection = " & MyCodeSelection

'Initialize New Event API_File_Exists
'API FileExists: Returns True of False If a File Exists
'IF FileExists = True Then Kill

If FileExists(TempCRCFile) = True Then
Debug.Print "File Exists: = True"
'<Drive>:\<Drive> Temp.CRC OR
'<Drive>\Folder\FirstFolder Temp.CRC OR
'<Drive>:\Folder\Folder...\<Drive> FirstFolder TO LastFolder
Temp.CRC
Kill (TempCRCFile)
Else
Debug.Print "File Exists: = False"
End If

If FileExists(TempTXTFile) = True Then
Debug.Print "File Exists: = True"
'<Drive>:\<Drive> Report.txt OR
'<Drive>\Folder\FirstFolder Report.txt OR
'<Drive>:\Folder\Folder...\<Drive> FirstFolder TO
LastFolder Report.txt
Kill (TempTXTFile)
Else
Debug.Print "File Exists: = False"
End If

If FileExists(strVerify) = True Then
Debug.Print "File Exists: = True"
'<Drive>:\<Drive> Report.txt OR
'<Drive>\Folder\FirstFolder Report.txt OR
'<Drive>:\Folder\Folder...\<Drive> FirstFolder TO
LastFolder Report.txt
Kill (strVerify)
Else
Debug.Print "File Exists: = False"
End If

If FileExists("C:\Program Files\Dups\Batch Files\HashIt.bat") =
True Then
Debug.Print "Batch File Exists: = True"
Kill ("C:\Program Files\Dups\Batch Files\HashIt.bat")
Else
Debug.Print "Batch File Exists: = False"
End If

'Initialize New Event Writing_out_Temporal_CRC_File
'Initialize Variables

ccgFF = FreeFile()

'Writing out a Temporal .CRC file:
'<Drive>:\<Drive> Temp.CRC OR
'<Drive>\Folder\FirstFolder Temp.CRC OR
'<Drive>:\Folder\Folder...\<Drive> FirstFolder TO LastFolder
Temp.CRC
'In order to add this file into the Hash File without user
intervention (Writing out a Temporal batch file)

Open TempCRCFile For Output As #ccgFF
Close #ccgFF ' Close file

'Initialize New Event Writing_out_Temporal_Report_TXT_File
'Initialize Variables

egfFF = FreeFile()

'Writing out a Temporal Report TXT file:
'<Drive>:\<Drive> Report.txt OR
'<Drive>\Folder\FirstFolder Report.txt OR
'<Drive>:\Folder\Folder...\<Drive> FirstFolder TO LastFolder
Report.txt
'In order to add this file into the Hash File without user
intervention (Writing out a Temporal batch file)

Open TempTXTFile For Output As #egfFF
Print #egfFF, "============ 00/00/0000 00:00:00 AM/PM
============"
Print #egfFF, "-- Results --"
Print #egfFF, "Info"
Print #egfFF, "- date: 00/00/0000"
Print #egfFF, "- process: Hash"
Print #egfFF, "- source: <Drive>:\<Folder>"
Print #egfFF, "- source volume label: Volume Name"
Print #egfFF, ' Write blank line.
Print #egfFF, "Basic statistics"
Print #egfFF, "- time elapsed: 00:00:00"
Print #egfFF, "- overall transfer [kB/s]:
000000000000,000000000000"
Print #egfFF, "- folders processed: 000000000000"
Print #egfFF, "- files processed: 00000000000000"
Print #egfFF, "- source bytes read: 000000000000 MB
(000000000000,000000000000,000000000000 bytes)"
Print #egfFF, "- source average transfer [kB/s]:
000000000000,000000000000"
Print #egfFF, "- source clean transfer [kB/s]:
000000000000,000000000000"
Print #egfFF, ' Write blank line.
Print #egfFF, "Errors"
Print #egfFF, "- errors: 000000000000"
Print #egfFF, "- warnings: 0000000000"
Print #egfFF, "- other: 0000000000000"
Print #egfFF, ' Write blank line.
Print #egfFF, "-- Messages --"
Print #egfFF, "note;hash;Hash file created (code:
0000000000000);<Drive>:\<Folder>:\File.CRC"
Print #egfFF, "note;hash;Hash file created (code:
0000000000000);<Drive>:\<Folder>:\File.CRC"
Print #egfFF, "note;hash;Hash file created (code:
0000000000000);<Drive>:\<Folder>:\File.CRC"
Close #egfFF ' Close file.

'Initialize New Event
API_Folder_Exists_And_CreateDirectory_Nested_Folders
'API Folder Exists
'Checks IF the Folder exists, IF NOT THEN create it
If FolderExists("C:\Program Files\Dups\Batch Files") = True Then
'Folder exists
Debug.Print "Folder Exists"
Else
'API CreateDirectory Nested Folders
'Folder does not exist
MsgBox "Folder Does not exits"
newDirectory = "C:\Program Files\Dups\Batch Files"
CreateNestedFoldersByPath (newDirectory)
Debug.Print "Folder Does not Exists"
End If

'Initialize New Event Writing_out_batch_file_CDCheck
'Initialize Variables

amcFF = FreeFile()

'Writing out a batch file (.bat or .vbs) using VBA
'Working and Tested Solution
'Determine IF is <Drive>:\ OR <Drive>:\Folder OR <Drive>:\Folder
\Folder...
'Please note: Very Sensitive if the user opens a file the hash
change
If MyCodeSelection = 1 Then

Open "C:\Program Files\Dups\Batch Files\HashIt.bat" For
Output As #amcFF
Print #amcFF, "CD /D " & Chr(34) & Environ("ProgramFiles")
& "\CDCheck" & Chr(34)
Print #amcFF, "START /WAIT CDCheck /CRC:MD5 " & Chr(34) &
GetFolder & Chr(34) & Chr(32) & _
"/O:" & Chr(34) & GetFolder & strDrive & ".CRC" & Chr(34)
& Chr(32) & _
"/SaveReport:" & Chr(34) & GetFolder & strDrive & "
Report" & ".txt" & Chr(34)
Close #amcFF

ElseIf MyCodeSelection = 2 Then

Open "C:\Program Files\Dups\Batch Files\HashIt.bat" For Output
As #amcFF
Print #amcFF, "CD /D " & Chr(34) & Environ("ProgramFiles")
& "\CDCheck" & Chr(34)
Print #amcFF, "START /WAIT CDCheck /CRC:MD5 " & Chr(34) &
GetFolder & Chr(34) & Chr(32) & _
"/O:" & Chr(34) & GetFolder & "\" & FirstFolder & ".CRC" &
Chr(34) & Chr(32) & _
"/SaveReport:" & Chr(34) & GetFolder & "\" & FirstFolder &
" Report" & ".txt" & Chr(34)
Close #amcFF

ElseIf MyCodeSelection = 3 Then

Open "C:\Program Files\Dups\Batch Files\HashIt.bat" For Output
As #amcFF
Print #amcFF, "CD /D " & Chr(34) & Environ("ProgramFiles")
& "\CDCheck" & Chr(34)
Print #amcFF, "START /WAIT CDCheck /CRC:MD5 " & Chr(34) &
GetFolder & Chr(34) & Chr(32) & _
"/O:" & Chr(34) & GetFolder & "\" & strDrive & " " &
FirstFolder & " TO " & LastFolder & _
".CRC" & Chr(34) & Chr(32) & _
"/SaveReport:" & Chr(34) & GetFolder & "\" & strDrive & "
" & FirstFolder & " TO " & _
LastFolder & " Report" & ".txt" & Chr(34)
Close #amcFF

End If

Debug.Print "MyCodeSelection = " & MyCodeSelection

MsgBox "Termine el Hash"

'Initialize New Event Make_Access_Wait
'Make Access wait till It is done with other application
MsgBox "Rutina ShellWait"
Call ShellWait("C:\Program Files\Dups\Batch Files\HashIt.bat")
'Implement a wait period in Access where the duration can be
'increased/decreased bychanging the constant to a corressponding
higher/lower value
MsgBox "Rutina sSleep"
Call sSleep(9000)

Next VBA statment <----

End Sub
 
R

rebelscum0000

HI, Doug

I Found that if I changed

Call ShellWait("C:\Program Files\Dups\Batch Files\HashIt.bat") for :

Call ShellWait("cmd.exe /c ""C:\Program Files\Dups\Batch Files
\HashIt.bat""")

The API: Shell and Wait, by Terry Kreft now is working and I do not
need anymore The API: Make code go to Sleep by by Dev Ashish,
that is what I wanted

Thank you very much for your help!
Regards
Antonio Macias
 
D

Douglas J. Steele

Just in case you've got users with old operating systems, it's probably
better to use

Call ShellWait(Environ("ComSpec") & " /c ""C:\Program Files\Dups\Batch
Files\HashIt.bat""")

(in some operating systems, you'd need

Call ShellWait("command.exe /c ""C:\Program Files\Dups\Batch
Files\HashIt.bat""")

The ComSpec environment variable should indicate the correct one to use.
 
R

rebelscum0000

Hi Doug
Just in case you've got users with old operating systems, it's probably
better to use

Wooooooow! Thank you for addionals code you provide me in case the
user run my DB in older OS

Regards
Anotnio Macias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top