1.

Solve : Kill wscript.exe without WMI service permission?

Answer»

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.

GregGreg, If it is your laptop, why don't you have admin rights?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. Quote from: Geek-9pm on May 29, 2013, 03:47:09 PM
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.Quote from: Sidewinder on May 30, 2013, 04:10:11 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.

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


Discussion

No Comment Found