+ Post New Thread
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 31
Coding Thread, error with WaitForExit() in Coding and Web Development; Hi LosOjos Still...
  1. #16

    Join Date
    Aug 2013
    Posts
    39
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Hi LosOjos

    Still

  2. #17

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,671
    Thank Post
    1,484
    Thanked 1,266 Times in 860 Posts
    Rep Power
    804
    Just to check, are you importing the necessary dependencies?

    Code:
    Imports System
    Imports System.Diagnostics
    Imports System.ComponentModel

  3. #18
    SovietRussia's Avatar
    Join Date
    Mar 2013
    Location
    Powys, Wales
    Posts
    696
    Thank Post
    76
    Thanked 158 Times in 123 Posts
    Rep Power
    49
    Quote Originally Posted by LosOjos View Post
    Missing a step:

    Code:
    Dim myProcess_uninstall As New Process
    Dim startInfo As New ProcessStartInfo
    startInfo.FileName = "cscript"
    startInfo.Arguments = "C:\Users\admin\Desktop\OffScrub10.vbs"
    myProcess_uninstall = Process.Start(startInfo)
    myProcess_uninstall.WaitForExit()
    Sorry! My VB is rusty, I am a C# developer and tried to port it over -epicfail

  4. #19

    Join Date
    Aug 2013
    Posts
    39
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Hi LosOjos I have imported the dependencies and still not working

  5. #20

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,671
    Thank Post
    1,484
    Thanked 1,266 Times in 860 Posts
    Rep Power
    804
    I think we're going to need to see more of your code, there's no reason the code you've been given shouldn't work unless there's a problem elsewhere in the code...

  6. #21

    Join Date
    Aug 2013
    Posts
    39
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Ok, this is my full code

  7. #22

    Join Date
    Aug 2013
    Posts
    39
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Option Explicit Off
    Imports System.IO
    Imports System.Windows.Forms
    Imports System.Xml
    Imports System.Deployment.Application
    Imports System.Collections.Specialized
    Imports Microsoft.VisualBasic
    Imports System.Windows.Forms.VisualStyles.VisualStyleEleme nt.TaskbarClock
    Imports System
    Imports System.Diagnostics
    Imports System.ComponentModel


    Public Class Form1


    Private Property WScript As Object
    Public objNetwork As New Object
    Dim ServerName
    Dim ShareName
    Dim ShareLetter
    Dim myProcess_uninstall As Process = Nothing
    Dim myProcess_install As Process = Nothing

    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs)
    End Sub
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    End Sub
    Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    End
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Me.Close()
    '======================== MAP NETWORK DRIVE ===================
    'Name of the server where the share exists
    ServerName = "KBC-PC"
    'The name of the shared folder
    ShareName = "office_2013"
    'The letter that will appear on the users machine
    ShareLetter = "u:"


    objNetwork = CreateObject("WScript.Network")
    objNetwork.MapNetworkDrive(ShareLetter, "\\" & ServerName & "\" & ShareName)

    '================= UNINSTALL OFFICE 2010 =======================

    myProcess_uninstall = Process.Start("C:\Users\admin\Desktop\OffScrub10.v bs")
    myProcess_uninstall.WaitForExit()

    '================== INSTALL OFFICE 2013 =====================
    myProcess_install = Process.Start("C:\office_2013\setup.EXE")
    myProcess_install.WaitForExit()
    '================ DISCONNECT NETWORK DRIVE ==================
    objNetwork.RemoveNetworkDrive(ShareLetter)

    End Sub




    End Class

    Please I need your help ASAP

    Regards
    Last edited by engineer_z; 25th November 2013 at 05:57 PM.

  8. #23

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,671
    Thank Post
    1,484
    Thanked 1,266 Times in 860 Posts
    Rep Power
    804
    OK, you don't appear to have implemented the changes we've been suggesting, plus there's a rogue space in the file name of the script you're calling....

    should be .vbs not .v_bs

  9. #24

    Join Date
    Aug 2013
    Posts
    39
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    hi. Even with after updating the changes that you told me , still the same error. And the a bout the file name it complies the start function correctly and opens the file but the waitfor exit function does not work.
    Regards

  10. #25

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,671
    Thank Post
    1,484
    Thanked 1,266 Times in 860 Posts
    Rep Power
    804
    Quote Originally Posted by engineer_z View Post
    hi. Even with after updating the changes that you told me , still the same error. And the a bout the file name it complies the start function correctly and opens the file but the waitfor exit function does not work.
    Regards
    Try moving the Me.Close() line to the end of the sub routine

  11. #26

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,671
    Thank Post
    1,484
    Thanked 1,266 Times in 860 Posts
    Rep Power
    804
    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?

  12. #27

    Join Date
    Aug 2013
    Posts
    39
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    The process started but the waitforexit() function does not work

  13. #28

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,671
    Thank Post
    1,484
    Thanked 1,266 Times in 860 Posts
    Rep Power
    804
    Quote Originally Posted by engineer_z View Post
    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?

  14. #29

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,671
    Thank Post
    1,484
    Thanked 1,266 Times in 860 Posts
    Rep Power
    804
    I just threw together a VB project in 5 minutes using the advice in this thread and it works fine:

    Code:
    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.

  15. #30

    Join Date
    Aug 2013
    Posts
    39
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    YEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE EEEEEEEEEEEEEEEEEEEEES IT'S WORKEEEEED
    DIG THANKS FOR YOU LosOjos , YO
    U REALY SAVED MY LIFE AND THAKS ALL YOU GUYS FOR YOUR REPLIES

    Regards



SHARE:
+ Post New Thread
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Replies: 5
    Last Post: 21st January 2009, 09:58 AM
  2. DFS/FRS error with removing an old server
    By FatBoy in forum Windows
    Replies: 2
    Last Post: 23rd October 2008, 11:05 AM
  3. Error with NEW SSL Cert in OWA
    By ICTNUT in forum Windows
    Replies: 3
    Last Post: 15th November 2007, 09:35 AM
  4. Cachepilot error with myLGFL
    By philtomo-25 in forum Windows
    Replies: 2
    Last Post: 27th June 2007, 11:45 AM
  5. Stupid CMD error with logon script
    By tarquel in forum Windows
    Replies: 37
    Last Post: 14th June 2006, 10:07 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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