Solved

Kill excel process on Windows 8 server

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

INTRODUCTION The purpose of this document is to demonstrate the Installation and configuration of the Data Protection Manager product. Note that this demonstration was prepared on the basis of Windows OS is 2008 R2 and DPM 2010. DATA PROTECTI…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
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…

708 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

18 Experts available now in Live!

Get 1:1 Help Now