?
Solved

Kill excel process on Windows 8 server

Posted on 2013-12-25
5
Medium Priority
?
726 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 76

Accepted Solution

by:
Alan Hardisty earned 668 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 668 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 70

Assisted Solution

by:Qlemo
Qlemo earned 664 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 70

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

Limited time offer using promo code EXPERTS30

Designed with a wealth of functionality and convenience, ATEN's new Thunderbolt™ 2 Sharing Switch takes your Thunderbolt setup to the next level. Now through September 15, 2017, Experts Exchange members get 30% off the US7220 on the ATEN USA eShop using promo code EXPERTS30.

Question has a verified solution.

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

Determining the an SCCM package name from the Package ID
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

765 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