Running vbs script from Access

Harris@Z

Registered User.
Local time
Tomorrow, 00:52
Joined
Oct 28, 2019
Messages
104
Hi, hope someone can help!
I trigger a vbs script (update.vbs) when a form closes, which is meant to trigger a batch file (update.bat).
The reason for doing it this way is to keep the process hidden.
I have included text messages in both when testing to ensure that each works.

When I trigger update.vbs itself, it works and triggers update.bat successfully.
However, when update.vbs is triggered when the form closes, it appears to run for the message pops up, but the .bat file is not triggered

I would even be happy to have the update.bat file run on its own, but cannot get this to work.

Can anyone advise?
Thanks, Harris
 
why vbs then call bat, can you not use Shell to execute the bat?
 
Used these:
Call shell(Environ$("COMSPEC") & " /p H:\My Documents\AccessDatabases\UpdateDB.bat", vbNormalFocus)

Dim RetVal
RetVal = shell("H:\My Documents\AccessDatabases\UpdateDB.bat", 0)

Neither worked
 
can you copy the .bat to your CurrentProject.Path folder and run it there?
you also need to update the .bat file to fix any Path inside the .bat.
 
The .bat file is in my CurrentProject.Path

I have accidentally found this to work!
shell "cmd /c ""H:\My Documents\AccessDatabases\UpdateDB.bat""", vbNormalFocus

However can you advise on how to change the path using CurrentProject.Path?
I have tried various ways and simply cannot get the .bat to then execute.

Even tried this:
Dim BatName As String
BatName = Chr(34) & Chr(34) & " " & CurrentProject.Path & "\UpdateDB.bat" & Chr(34) & Chr(34)
Debug.Print BatName

shell "cmd /c & BatName & ", vbNormalFocus

Thanks for your help!
 
The .bat file is in my CurrentProject.Path

I have accidentally found this to work!
shell "cmd /c ""H:\My Documents\AccessDatabases\UpdateDB.bat""", vbNormalFocus

However can you advise on how to change the path using CurrentProject.Path?
I have tried various ways and simply cannot get the .bat to then execute.

Even tried this:
Dim BatName As String
BatName = Chr(34) & Chr(34) & " " & CurrentProject.Path & "\UpdateDB.bat" & Chr(34) & Chr(34)
Debug.Print BatName

shell "cmd /c & BatName & ", vbNormalFocus

Thanks for your help!
Have you tried?

Code:
batName="cmd /c """ & CurrentProject.Path & "\UpdateDB.bat"""
Shell batName
 
what does the .bat file actually do?

you can't update a database file while you are using it. Maybe the .bat file commands just fail.
 
Excellent, worked like a charm.
Syntax is obviously everything!

Thank you very much for your help. Much appreciated
 
Excellent, worked like a charm.
Syntax is obviously everything!

Thank you very much for your help. Much appreciated
Hi. Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom