vb.net - Issue with overlapping batch file runs -
i having issue in script things running sequentially. have initial script decompile swf. second searches 1 string in 1 of decompiled files , third recompiling new swf.
how can make each process wait until completes before next started?
i having trouble making second script work. nice if display replaced after finished.
here script far:
imports system.net public class form3 private sub button7_click(sender system.object, e system.eventargs) handles button7.click if textbox4.text = "" messagebox.show("please select directory") else dim fd openfiledialog = new ope nfiledialog() dim strfilename string fd.title = "open file dialog" fd.initialdirectory = textbox1.text fd.filter = "all files (*.*)|*.*|all files (*.*)|*.*" fd.filterindex = 2 fd.restoredirectory = true if fd.showdialog() = dialogresult.ok strfilename = fd.filename if instr(strfilename, ".swf") <> 0 textbox2.text = strfilename else messagebox.show("you have pick .swf silly...") end if end if end if end sub private sub button8_click(sender system.object, e system.eventargs) handles button8.click me.close() end sub private sub button1_click(sender system.object, e system.eventargs) handles button1.click dim folder = textbox4.text & "\hexed" if textbox2.text = "" messagebox.show("you have pick .swf silly...") else if my.computer.filesystem.directoryexists(folder) my.computer.filesystem.deletedirectory(folder, fileio.deletedirectoryoption.deleteallcontents) end if my.computer.filesystem.copydirectory("c:\users\matt\documents\my_games\rotmg\shadygamer\windowsapplication1\windowsapplication1\rabcdasm", folder) my.computer.filesystem.copyfile(textbox2.text, folder & "\client.swf", true) dim file_name string = folder & "\decompile.bat" dim integer dim arytext(4) string arytext(0) = "cd " & folder arytext(1) = "swfdecompress client.swf" arytext(2) = "abcexport client.swf" arytext(3) = "rabcdasm client-1.abc" dim objwriter new system.io.streamwriter(file_name, false) = 0 3 objwriter.writeline(arytext(i)) next objwriter.close() dim psi new processstartinfo(folder & "\decompile.bat") psi.redirectstandarderror = true psi.redirectstandardoutput = true psi.createnowindow = false psi.windowstyle = processwindowstyle.hidden psi.useshellexecute = false dim decompile new process process.start(psi) messagebox.show("click step 2") button1.visible = false button3.visible = true end if end sub private sub textbox4_textchanged(sender system.object, e system.eventargs) handles textbox4.textchanged end sub private sub button2_click(sender system.object, e system.eventargs) handles button2.click dim myfolderbrowser new system.windows.forms.folderbrowserdialog myfolderbrowser.description = "select folder" myfolderbrowser.shownewfolderbutton = false dim dlgresult dialogresult = myfolderbrowser.showdialog() if dlgresult = windows.forms.dialogresult.ok textbox4.text = myfolderbrowser.selectedpath end if end sub private sub button3_click(sender system.object, e system.eventargs) handles button3.click dim folder = textbox4.text & "\hexed" const quote string = """" dim myfile string = folder & "\client-1\com\company\assembleegameclient\parameters\parameters.class.asasm" replace(myfile, quote & textbox1.text & quote, quote & textbox3.text & quote) messagebox.show("click step 3") button3.visible = false button4.visible = true end sub private sub button4_click(sender system.object, e system.eventargs) handles button4.click dim folder = textbox4.text & "\hexed" dim file_name2 string = folder & "\recompile.bat" dim j integer dim arytext2(4) string arytext2(0) = "cd " & folder arytext2(1) = "rabcasm client-1\client-1.main.asasm" arytext2(2) = "abcreplace client.swf 1 client-1\client-1.main.abc" dim objwriter2 new system.io.streamwriter(file_name2, false) j = 0 2 objwriter2.writeline(arytext2(j)) next objwriter2.close() dim ps new processstartinfo(folder & "\recompile.bat") ps.redirectstandarderror = true ps.redirectstandardoutput = true ps.createnowindow = false ps.windowstyle = processwindowstyle.hidden ps.useshellexecute = false dim recompile process = process.start(ps) my.computer.filesystem.copyfile(folder & "\client.swf", textbox4.text & "\hexed.swf", true) end sub end class
you can use process.waitforexit()
- msdn here - http://msdn.microsoft.com/en-us/library/system.diagnostics.process.waitforexit.aspx
update
you'll need change way start process use this:
dim ps new system.diagnostics.process() dim psi new system.diagnostics.processstartinfo(folder & "\decompile.bat") psi.redirectstandarderror = true psi.redirectstandardoutput = true psi.createnowindow = false psi.windowstyle = processwindowstyle.hidden psi.useshellexecute = false ps.startinfo = psi ps.start() ps.waitforexit()
Comments
Post a Comment