Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Kill wscript.exe without WMI service permission  (Read 8735 times)

0 Members and 1 Guest are viewing this topic.

gsnidow

    Topic Starter


    Rookie

  • Just a guy trying to make work stuff easier
    • Experience: Beginner
    • OS: Unknown
    Kill wscript.exe without WMI service permission
    « on: May 29, 2013, 02:09:11 PM »
    Greetings all.  I'm on Windows 7 professional, and I do not have admin rights.  I use many VBScript files, and have no issue there.  My issue is that every time I run one of them, the wscript.exe process is left running.  If there gets to be several instances of it the cpu usage spikes, the fan goes into overdrive, and my laptop sounds like a jet about to take off until I manually kill them all using the task manager.  This is what I have tried.

    - Put wscript.quit at the end of the script: does not seem to do anything.

    - call the script files from a batch file, using both cscript.exe and wscript.exe.  I read several posts on this issue, and there seemed to be some success for some folks, but both cscript.exe and wscript.exe are left running.

    - call the script files from the command prompt, and same as above.

    I found http://technet.microsoft.com/en-us/library/ee692847.aspx#EGAA, and was hopefull when reading the section "Listing 2: Terminating Processes".  However, I do not have the ability to access WMI.  At this point I am at a total loss as to what else I can do.  I sure would appreciate any other method anyone could offer.  Thank you.

    Greg

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Kill wscript.exe without WMI service permission
    « Reply #1 on: May 29, 2013, 03:47:09 PM »
    Greg, If it is your laptop, why don't you have admin  rights?

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: Kill wscript.exe without WMI service permission
    « Reply #2 on: May 30, 2013, 04:10:11 AM »
    Quote
    My issue is that every time I run one of them, the wscript.exe process is left running

    Please post one of the scripts giving you problems. Your problem can be recreated by using the RUN method to start a secondary program/script and waiting for a return that never happens.

    Does this only happen with WScript/CScript?

    Just a thought.  8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    gsnidow

      Topic Starter


      Rookie

    • Just a guy trying to make work stuff easier
      • Experience: Beginner
      • OS: Unknown
      Re: Kill wscript.exe without WMI service permission
      « Reply #3 on: May 30, 2013, 07:08:05 AM »
      Greg, If it is your laptop, why don't you have admin  rights?

      Sorry for the lack of info.  It is a work laptop, and once we transitioned to W7, all admin rights gone.  Most people had them with XP, but now I cannot rely on it if I am writing a script for others.  Thank.

      gsnidow

        Topic Starter


        Rookie

      • Just a guy trying to make work stuff easier
        • Experience: Beginner
        • OS: Unknown
        Re: Kill wscript.exe without WMI service permission
        « Reply #4 on: May 30, 2013, 08:06:48 AM »
        Please post one of the scripts giving you problems. Your problem can be recreated by using the RUN method to start a secondary program/script and waiting for a return that never happens.

        Does this only happen with WScript/CScript?

        Just a thought.  8)

        Sidewinder, here is a sample script that just pulls some data from a database.  Note, I changed the DSN name and query and all that, not that it would mean anything to anyone, but just covering my rear.  Anyhow, this script works exactly as it should, but leaves wscript.exe running after it is done.
        Code: [Select]
        Set cn = CreateObject("ADODB.Connection")
        Set rs = CreateObject("ADODB.Recordset")

        userid = inputbox("Enter EID")
        password = inputbox("Enter password")

        strSQL = "SELECT SomeColumn FROM SomeTable"

        cn.Open "DSN=SomeDSN;Password=" & Trim(password) & ";User ID=" & Trim(userid) & ";"

        Set rs = cn.Execute(strSQL)
        With rs
        .movefirst
        While Not (.EOF AND .BOF)
        On Error Resume Next
        MsgBox "Col1   = " & .fields(0) & vbcrlf & _
           "Col2 = " & .fields(1)
        .MoveNext
        Wend
        End with

        rs.close
        Set rs = nothing
        Set cn = nothing

        Wscript.quit

        Just for grins, I put 'MsgBox "Hello"' in a script, with nothing else, and it did not leave an instance of wscript running, so I wonder if it has something to do with the objects.  Just to test, here is another simple one that *does not* leave wscript.exe running.
        Code: [Select]

        Set wshShell = CreateObject("WScript.Shell")
        Set objFSO = CreateObject("Scripting.FileSystemObject")

        strFilePath = wshShell.ExpandEnvironmentStrings("%temp%") & "\Test.txt"

        If objFSO.FileExists(strFilePath) Then
        'Delete the file if it exists
        objFSO.DeleteFile(strFilePath)
        End if

        set WriteText = objFSO.CreateTextFile(strFilePath)
        WriteText.WriteLine("Hello")

        Set objFSO = nothing
        Set WriteText = nothing

        gsnidow

          Topic Starter


          Rookie

        • Just a guy trying to make work stuff easier
          • Experience: Beginner
          • OS: Unknown
          Re: Kill wscript.exe without WMI service permission
          « Reply #5 on: May 30, 2013, 10:34:43 AM »
          I got it now.

          I had "While Not (.EOF AND .BOF)" where I should have had only "While Not (.EOF)".  I copied from one of my Access VBA scripts without thinking.  Thanks all.