Jump to content

Recommended Posts

Posted
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?
Posted
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?

Posted

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.

Posted

YEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEES IT'S WORKEEEEED:whoo:

DIG THANKS FOR YOU LosOjos , YOU REALY SAVED MY LIFE AND THAKS ALL YOU GUYS FOR YOUR REPLIES

Regards

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...