[RESOLVED] Can't get Process.Start to work on IIS7/Server 2008 (oops it's SBS 2011!)
[edit]actually it's SBS 2011[/edit]
I cannot get PROCESS.START to work on a Server 2008 box - tried all kinds of credential settings - getting no where.
I recently added the un/pw stuff - if I put a bad username it gives me an error - but with a good one nothing happens - the process never starts.
Code:
Dim strFile As String = "Report_" & rptid & ".bat"
Dim strBatFile As String = Path.Combine(strReportFolder, strFile)
Using fileWrtr = New StreamWriter(strBatFile, False)
fileWrtr.WriteLine("CD /D " & strReportFolder)
fileWrtr.WriteLine("set path=" & strReportFolder)
'fileWrtr.WriteLine("amc rpt/printers")
fileWrtr.WriteLine(strCmd)
fileWrtr.Close()
End Using
Dim psusername As String = "xxxxx"
Dim pspassword As SecureString = ConvertToSecureString("passwordxxxx")
Dim psdomain As String = "somedomain"
If blnSubmit Then
Try
Process.Start(strBatFile, psusername, pspassword, psdomain)
.StartObject()
.NewObject("rptid", rptid)
.Seperate()
.NewObject("queued", IIf(blnSubmit, "N", "Y").ToString)
.EndObject()
Catch ex As Win32Exception
.StartObject()
.NewObject("%%dalerror%%", ex.Message)
.EndObject()
Catch ex As Exception
.StartObject()
.NewObject("%%dalerror%%", ex.Message)
.EndObject()
End Try
End If
Last edited by szlamany; Apr 1st, 2012 at 06:49 PM.
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".
Re: Can't get Process.Start to work on IIS7/Server 2008
I don't have access to the server to make changes like that myself...
I'm currently trying to debug this - detect any errors - on the started process.
Code now looks like this
Code:
Dim prc As New ProcessStartInfo
prc.WorkingDirectory = strReportFolder
prc.FileName = strBatFile
prc.UserName = psusername
prc.Password = pspassword
prc.Domain = psdomain
prc.UseShellExecute = False
prc.RedirectStandardError = True
Dim runningproc As Process = Process.Start(prc) ' strBatFile, psusername, pspassword, psdomain)
Dim sr As StreamReader = runningproc.StandardError
Dim xyz As String = sr.ReadToEnd
.StartObject()
.NewObject("%%dalerror%%", xyz)
.EndObject()
When I was missing this line of code
prc.RedirectStandardError = True
it gave me an error telling me that error output had not been re-directed - making me think it is starting.
How can I debug more of this process that I've started???
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".
Re: Can't get Process.Start to work on IIS7/Server 2008
Ok - so now I got it doing this...
Process.Start is "starting" amcReport.exe - as you can see in the TASKMGR screen shot below.
And you can also see that amcReport.log has been created - it's showing in that folder.
This is the code that does that (this is an old VB6 program being "started" to run a report")
Code:
If gCommandLine = True Then
Open "amcReport.log" For Append as #1
Print #1, "-----------------------------------------"
Call ReadIni
Call CommandLine(s1)
Call TerminateConnection
Print #1, "Closing"
Close #1
But awcReport.exe never gets any CPU time - it never runs...
I think it might be having a UAC problem - but I can't imagine how it got as far as "creating" that amcReport.LOG file!
If I use TASKMGR to kill amcReport.exe the .LOG file doesn't even show the line of "------------" - what's up with that?? File I/O doesn't complete properly when you TASKMGR to kill a process...
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".
Re: Can't get Process.Start to work on IIS7/Server 2008
I guess i meant if you have access to make the changes of the article because you said you didn't have access before.
Also maybe this will give some help? http://www.vbforums.com/showthread.php?t=622626
Re: Can't get Process.Start to work on IIS7/Server 2008
It's a brand new Windows SBS 2011 box that my customer just got installed - I'm working with it over RDP and not really comfortable messing with security settings and such.
I'm considering at the moment creating my own Windows Service to do the PROCESS.START so I have ultimate control over the un/pw credentials that the service runs under.
Hope I don't do all that to find out the UAC burns me in that situation as well!
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".
Re: Can't get Process.Start to work on IIS7/Server 2008
Well don't overload the service or something.Just create a simple one for testing.
Another thought that might or might not work is using impersonation.But i have never tried it in something newer that WS2003 and i don't know if it will even impact with the UAC.
Also do you need the process or you will code something new using the service?That looks like a better solution if you can do it.
Last edited by sapator; Apr 1st, 2012 at 05:17 PM.