works in vs 2008 but not outside
So my vb program works inside of vs 2008 with the code below but when i build it and put it in windows home server it crashes. The problem is with the if statement. If i take it out the program works just fine. the if statement searches the output from the shell.
Code:
schedule = "SCHTASKS /Create /SC " & Often & " /RU Administrator /RP " & password & " /ST " & TextTime.Text & ":00" & " /TN " & title & " /TR " & path & " > C:\copypal\slogs\" & title & ".txt"
Shell("cmd /c" & schedule, vbHide)
Dim sFileBuffer As String, sSearchValue As String, bValueExists As String
sSearchValue = "SUCCESS:" 'Value you are searching for
Dim oFile2 As System.IO.File
Dim oRead2 As System.IO.StreamReader
Dim keyread As String
oRead2 = oFile2.OpenText("C:\copypal\slogs\" & title & ".txt")
sFileBuffer = oRead2.ReadToEnd()
If InStr(1, sFileBuffer, sSearchValue, vbTextCompare) <> 0 Then
MsgBox(title & " has sucessfully been saved.")
Else
MsgBox(title & " failed. Please view the log located at C:\copypal\slogs\" & title & ".txt")
End If
Re: works in vs 2008 but not outside
What error message are you getting?
Re: works in vs 2008 but not outside
I am not getting an error, it crashes.
Re: works in vs 2008 but not outside
It crashes without an error message? I don't think I have ever seen that. What does it do?
Re: works in vs 2008 but not outside
this is an add-in for the windows home server console. First the console freezes then closes. thats it no error prompts. no telling me there was a problem
Re: works in vs 2008 but not outside
I am wondering if it is taking too long to create the output from the shell. then the if statement is looking for a file that is not there so it freezes
Re: works in vs 2008 but not outside
how could i have the vb pause between the shell and the if?
Re: works in vs 2008 but not outside
Very nice. It must be quietly absorbing the error without giving you any hint. There are sound reasons to do that, especially for some services, but it can certainly make debugging kind of interesting, as you have to guess at the problem.
I see no error handling in the code that you posted. What I would do would be to wrap the whole thing in a Try...Catch block and either use a messagebox to show the error message, or, since you might not want messageboxes popping up, write the error to a log file. One way or another, you really need to get the message from the exception or you will mostly be groping in the dark.