VB.NET can't run shadow command in command prompt -
i trying run shadow command in cmd.exe vb programme reason not run command have tried few different things of have not worked. able save command batch file , execute success prefer pass argument/command command prompt straight , execute way. basically, have user run programme created extract sessionid , server name (i take server number off end). 4 digit passcode on end first 2 sessionid , lastly 2 server number (all our servers named ie smdts-(a number) care server number on) take 4 digit code , plug shadow admin program. here current code doesn't work:
private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click dim sessid string dim passcode string dim servnum string dim prc process passcode = textbox2.text sessid = passcode.substring(0, 2) servnum = passcode.substring(passcode.length - 2) dim fileargs string = " shadow" + " " & sessid + " " + "/server:smdts-" + servnum dim pinfo = new system.diagnostics.processstartinfo pinfo.filename = "cmd.exe" pinfo.arguments = fileargs pinfo.errordialog = false pinfo.useshellexecute = false pinfo.createnowindow = false pinfo.windowstyle = processwindowstyle.normal pinfo.redirectstandardoutput = false pinfo.redirectstandardinput = true pinfo.redirectstandarderror = false prc = new process prc.startinfo = pinfo prc.start() end sub
what work (batch file don't want use):
public class form1 public pathvar string = environment.getfolderpath(environment.specialfolder.personal) dim sessid string dim passcode string dim servnum string passcode = textbox2.text sessid = passcode.substring(0, 2) servnum = passcode.substring(passcode.length - 2) dim fileargs string = " shadow" + " " & sessid + " " + "/server:smdts-" + servnum dim streamwriter streamwriter streamwriter = file.createtext(pathvar + "\shadowbatch.bat") streamwriter.writeline(fileargs) streamwriter.close() shell(pathvar + "\shadowbatch.bat") end sub
any help on why first illustration not working appreciated! thanks!
tom k
you're passing shadow ...
arguments cmd. cmd not back upwards that.
instead, need pass /c shadow ...
, tell cmd execute command , exit.
alternatively run shadow
directly, without going through cmd.
vb.net command-line command process.start
No comments:
Post a Comment