similar to How do you run a .exe with parameters using vba's shell()?
Sub RunExe()
Dim wsh As Object
Set wsh = VBA.CreateObject("WScript.Shell")
Dim waitOnReturn As Boolean: waitOnReturn = True
Dim windowStyle As Integer: windowStyle = 1
Dim errorCode As Long
errorCode = wsh.Run("C:\dir\dir\dir\dir\dir\dir\dir\dir\dir\My.exe", windowStyle, waitOnReturn)
End Sub
The issue I am having is that the cmd line already starts in a folder with a different path. So when I run this code it starts down a path that I know the program is not in, I get the error:
Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path
'C:\dir\dir\dir\dir\dir'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.SetCurrentDirectory(String path)
at ReadDirectory(String directory)
at Program.Main(String[] args)
Is there some way to start back at c:\users? Or clear/flush the stream? This is where running run -> cmd.exe starts. But for some reason I have some memory in vba and starts in a different file path.