Thank you for your responses. I tried the Windows Script debugger, but it seems that it is for html and java codes. Well, here is the code I am having trouble with. It is a VB script called from MS Access to update the front end of an Access application. I got it from FAQ of Tek-Tips' Access Modules forum.
The Access function checks version numbers between a master copy and the users local copy, if different the following line of code is run:
fHandleFile "D:\db\VXP\UpdateFrontEnd.vbs", WIN_NORMAL
UpdateFrontEnd.vbs:
' * * * * Start * * * * *
Dim strLocalPath
Dim strNetPath
Dim FSO
strLocalPath = Left(WScript.scriptfullname, Len(WScript.scriptfullname) - Len(WScript.scriptname)) & "Projs.mdb"
strNetPath = "D:\db\VXP\Projs.mdb"
Set FSO = CreateObject("Scripting.FileSystemObject"
Do While FSO.FileExists(Left(strLocalPath, Len(strLocalPath) - 3) & "ldb"

= True
'As long as an ldb file exists, someone is in the database, so just do nothing until it goes.
Loop
Set WshShell = WScript.CreateObject("WScript.Shell"
FSO.CopyFile strNetPath, strLocalPath, True
WshShell.Run strLocalPath
' * * * * End * * * * *
fHandleFile Function:
' * * * * Start * * * * *
Private Function fHandleFile(stFile As String, lShowHow As Long)
Dim lRet As Long, varTaskID As Variant
Dim stRet As String
'First try ShellExecute
lRet = apiShellExecute(hWndAccessApp, vbNullString, _
stFile, vbNullString, vbNullString, lShowHow)
If lRet > ERROR_SUCCESS Then
stRet = vbNullString
lRet = -1
Else
Select Case lRet
Case ERROR_NO_ASSOC:
'Try the OpenWith dialog
varTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " _
& stFile, WIN_NORMAL)
lRet = (varTaskID <> 0)
Case ERROR_OUT_OF_MEM:
stRet = "Error: Out of Memory/Resources. Couldn't Execute!"
Case ERROR_FILE_NOT_FOUND:
stRet = "Error: File not found.Couldn't Execute!"
Case ERROR_PATH_NOT_FOUND:
stRet = "Error: Path not found. Couldn't Execute!"
Case ERROR_BAD_FORMAT:
stRet = "Error:Bad File Format. Couldn't Execute!"
Case Else:
End Select
End If
fHandleFile = lRet & _
IIf(stRet = "", vbNullString, ", " & stRet)
End Function
' * * * * End * * * * *
Here are the constants declaration used in the above function:
Private Const ERROR_SUCCESS = 32&
Private Const ERROR_NO_ASSOC = 31&
Private Const ERROR_OUT_OF_MEM = 0&
Private Const ERROR_FILE_NOT_FOUND = 2&
Private Const ERROR_PATH_NOT_FOUND = 3&
Private Const ERROR_BAD_FORMAT = 11&
Questions/issues:
1- When the code is run through Access of by double clicking the UpdateFrontEnd.vbs, the update does not take place. (?)
2- How can I use the debugger to step through the UpdateFrontEnd.vbs code to find out what is happening and where is it not working. When I open it through MS Script Debugger, all choices under "Debug" menu are greyed out.
3- Can you point me to a site where the apiShellExecute function is explained a bit.
Thanks a lot.
Shar