Solved

Kill excel process on Windows 8 server

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

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 69

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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sccm importing drivers 4 45
Windows 7 laptop upgraded to Windows 10 will not let me install Windows 7? 17 76
Windows Services - Run a Program Grey Out 3 60
Fatal Error 11 41
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
An article on effective troubleshooting
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

820 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