Solved

Kill excel process on Windows 8 server

Posted on 2013-12-25
5
681 Views
Last Modified: 2013-12-26
Hi,

I have a windows 8 server on which I have created 5 users to login with credentials.

Some times I need to close all the excel process running on all the 5 users and i created a vb script for it .

My script kill only the excel process only on the user I executed the script on remaining other users excel process is still running and not get killed.

Please suggest

I am using below script:
KillprocessIE ="EXCEL.EXE"
 Set ProcessList2 = GetObject("winmgmts://.").InstancesOf("win32_process")
 
For Each Process In ProcessList2
 If Process.Name = KillProcessIE Then
 Process.Terminate
 End If
 Next
Msgbox "All Excel Processes in your session have been terminated successfully"
0
Comment
Question by:theology
5 Comments
 
LVL 76

Accepted Solution

by:
Alan Hardisty earned 167 total points
ID: 39738942
If you run the following command on the server it will kill ALL excel processes running:

Taskkill /f /im excel.exe

Happy Christmas

Alan
0
 
LVL 16

Assisted Solution

by:Kalpesh Chhatrala
Kalpesh Chhatrala earned 167 total points
ID: 39738983
you can find Current User Name using Shell Script

    Set wshShell = WScript.CreateObject( "WScript.Shell" )
    strUserName = wshShell.ExpandEnvironmentStrings( "%USERNAME%" )

and you can compare Process Owner in your script before killing any process.
0
 
LVL 68

Assisted Solution

by:Qlemo
Qlemo earned 166 total points
ID: 39739067
taskkill should work, if you execute it as admin user. Unprivileged users will not see or have access to other users' processes.

taskkill can even be executed from another PC:
taskkill /s W8PC /U domain\admin /P AdminPwd /IM Excel.exe

Open in new window

0
 

Author Closing Comment

by:theology
ID: 39740071
Thank you all for your quick response.

Using your inputs I have modofied my code as:

Set oshell = createobject("Wscript.Shell")
    oshell.run"cmd.exe"
    wscript.sleep 500
    oshell.sendkeys "Taskkill /f /im excel.exe"""+("{Enter}")
    wscript.sleep 5000
    oshell.sendkeys "exit"+("{Enter}")
    set oshell = nothing
    WScript.Quit
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 39740991
Any reason why you do not start taskkill directly? Using SendKeys isn't an approach you should favour.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an article about Leadership and accepting and adapting to new challenges. It focuses mostly on upgrading to Windows 10.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now