Click here to Skip to main content
14,716,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an exe vb.net application and a bat file located in the same drive in different folders. Шhen I try to execute the bat file, it is executing properly. Problem occurs when I try to execute the file using the code.

What I have tried:

Private Sub runBatchFile()
Try
Dim Psi As New ProcessStartInfo("D:\TaskSchedular_W207\MysqlBackup_2.bat")
Psi.RedirectStandardError = True
Psi.RedirectStandardOutput = True
Psi.CreateNoWindow = False
Psi.WindowStyle = ProcessWindowStyle.Hidden
Psi.UseShellExecute = False

Dim process As Process = process.Start(Psi)
Catch
MessageBox.Show("Could not start process")
End Try


End Sub
Posted
Updated 17-Dec-20 2:09am
v2

1 solution

Probably it's a permissions problem: the task scheduler runs under a privileged account and your user doesn't, so you user who runs your app may not be able to access the file at all.
To find out, get the exception code in your catch block:
Catch ex As Exception
   MessageBox.Show("Could not start process: " & ex.Message)
End Try
And use the debugger to look at both the message and other info it contains.
   
Comments
Member 11893460 17-Dec-20 23:58pm
   
thank you! its working
OriginalGriff 18-Dec-20 2:00am
   
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900
人妻少妇波多野结衣_人妻少妇中文字幕久久_日本熟妇色一本在线视频