LosOjos Posted November 26, 2013 Posted November 26, 2013 Also, I know that it compiles with the space in the file extension, but does the script run? It would explain why it crashes at WaitForExit() - if the process never started, how can it wait for it to exit?
engineer_z Posted November 26, 2013 Author Posted November 26, 2013 The process started but the waitforexit() function does not work
LosOjos Posted November 26, 2013 Posted November 26, 2013 The process started but the waitforexit() function does not work Do you know the process started? i.e. did the script actually run and do what you expected? Also, did moving Me.Close() to the end of the sub routine make a difference?
LosOjos Posted November 26, 2013 Posted November 26, 2013 I just threw together a VB project in 5 minutes using the advice in this thread and it works fine: Imports System Imports System.Diagnostics Imports System.ComponentModel Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim startInfo As New ProcessStartInfo Dim myProcess As New Process startInfo.FileName = "CScript" startInfo.Arguments = """C:\Scripts\PC Name.vbs""" myProcess = Process.Start(startInfo) myProcess.WaitForExit() MsgBox("Done waiting") Me.Close() End Sub You must call Me.Close() at the end of the sub, otherwise it won't work. Makes sense, as that function will unload the form from memory, causing any further code within it to fail.
engineer_z Posted November 26, 2013 Author Posted November 26, 2013 YEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEES IT'S WORKEEEEED:whoo: DIG THANKS FOR YOU LosOjos , YOU REALY SAVED MY LIFE AND THAKS ALL YOU GUYS FOR YOUR REPLIES Regards
engineer_z Posted November 26, 2013 Author Posted November 26, 2013 the problem was with me.close() , it should be at the end with script.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now