Results 1 to 8 of 8

Thread: works in vs 2008 but not outside

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2010
    Posts
    20

    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

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: works in vs 2008 but not outside

    What error message are you getting?
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2010
    Posts
    20

    Re: works in vs 2008 but not outside

    I am not getting an error, it crashes.

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    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?
    My usual boring signature: Nothing

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2010
    Posts
    20

    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

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Feb 2010
    Posts
    20

    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

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Feb 2010
    Posts
    20

    Re: works in vs 2008 but not outside

    how could i have the vb pause between the shell and the if?

  8. #8
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    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.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width