multithreading - VB.NET Launching Batch File not working after install -
okay, 1 has me stumped beyond belief. have program installed on different machines supposed execute batch file after has completed specific task. batch file configured via our webservice user, , application pulls path string down , executes file @ path. should pretty simple/straightforward, right?
the code:
private function executebatchfile(batchfilepath string) string try dim psi new processstartinfo(batchfilepath) psi.redirectstandarderror = true psi.redirectstandardoutput = true psi.createnowindow = false psi.useshellexecute = false dim process process = process.start(psi) process.waitforexit() executebatchfile = process.exitcode catch ex exception strappstatus = "error within execution of batch file: " & ex.message logme(strappstatus) return "fail" end try end function
now, tricky part. code works when running in dev environment. have yet have issue. however, when application installed on computer (including same 1 ide installed on), when gets step in it's overall process calls function, not launch batch file. keep in mind, never throws exception, on either side. not return exitcode string, have other logging track well.
there 2 possibilities can think of in case. either a:) there permissions issue application not allowed launch batch files on computer installed on, or b:) sub called thread spun off main thread (i.e. using mythread = new system.threading.thread(addressof themainloop) mythread.start()
command).
still fact works 100% of time during compile , run phase in ide not after install blowing mind.
edit 1: did test placed button on main form itself, , click event same thing earlier function, , works, after install. leads me believe work if launched using main thread... think?
edit 2: batch file simple test batch opens text file, , know batch file , path both fine, because when compiled works fine. also, edit 1 stating created simple button executes same code above, , works fine after install. since done on main thread, , code earlier done in separate thread spun off original, wondering if cause of issue. other crazy thing logging catches if file launches or not, , acts if launching when have original issue. bah, whole thing nuts.
edit 3: added answer.
thanks tinstaafl, answer change useshellexecute true. had remove redirectstandarderror , redirectstandardoutput lines, wasn't using them anyways. on note, thank investigations, , if has idea why happened, ears.
Comments
Post a Comment