Solved

Kill excel process on Windows 8 server

Posted on 2013-12-25
5
714 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 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 70

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

705 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