dcsimg
Results 1 to 2 of 2

Thread: [RESOLVED] VBS doesn't complete it's script

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2011
    Posts
    167

    Resolved [RESOLVED] VBS doesn't complete it's script

    Hi guys,
    I have a VBScript that is loaded from my VB.NET application, in the vbs I have a command to kill the VB.NET that loads the vbs, checks a few things and runs the VB.NET again.
    VBScript code:
    Code:
    	if isProcessRunning(ProcessName) then
    		oShell.Run "taskkill /IM " & ProcessName & " /T /F", , True
    	End If
    
    Function isProcessRunning(ProcessName)
    	Dim objWMIService,strWMIQuery,Computer
    	Computer = "."
    	strWMIQuery = "Select * from Win32_Process where name like '" & ProcessName & "'"
    	
    	Set objWMIService = GetObject("winmgmts:" _
    		& "{impersonationLevel=impersonate}!\\" _ 
    			& Computer & "\root\cimv2") 
    
    
    	if objWMIService.ExecQuery(strWMIQuery).Count > 0 then
    		isProcessRunning = true
    	else
    		isProcessRunning = false
    	end if
    End Function
    VB.NET code:
    Code:
    Process.Start(Application.StartupPath & "\Load.vbs")
    The problem is, after the vbs kills the VB.NET application, the vbs also get killed and doesn't finish the script.
    Is there a way to fix that?
    Thanks

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    May 2011
    Posts
    167

    Re: VBS doesn't complete it's script

    Never mind, I found the solution... (thanks to Stackoverflow)
    I removed the /T from the taskkill command

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width