Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

Can I make a batch file to end a program?

I have an app that i use that requires a network connection. My laptop will lose the wireless connection 2 or 3 times a day but it immediately reconnects. The problem is once it has lost the connection you have to reopen the app for it to work again, but after losing the connection you can't even close the app without doing a ctrl/alt/del end task because it just pops up errors everytime you try to hit close... It would be nice if I could have a little batch file on my desktop that i could hit to end the task instead of having to go into ctrl/alt/del etc....
0
SOLOPCREPAIR
Asked:
SOLOPCREPAIR
  • 3
2 Solutions
 
taliesin1977Commented:
Not sure that a *simple* batch file can do that.

But here is a C# snippet to kill all instances of Excel. Substitute the process name you see in the task manager for "EXCEL".

1) Save this file as killMyApp.cs
2) Compile it from the command line with "csc /target:exe killMyApp.cs. This will generate killMyApp.exe
3) If this exe is some some path, C:\MyScripts\ for example, create a file with a .bat extension that contains only the line: C:\MyScripts\killMyApp.exe

class killMyApp
{
	static void Main(string[] args)
	{
 
		foreach (System.Diagnostics.Process proc in System.Diagnostics.Process.GetProcessesByName("notepad"))
                {                       
                   proc.Kill();
                }
	}
}

Open in new window

0
 
taliesin1977Commented:
Hehe, sorry, I didn't want to kill Excel on my machine, so I substituted "notepad" in the snippet above
0
 
taliesin1977Commented:
Or you can just create a shortcut to the exe file
0
 
SOLOPCREPAIRAuthor Commented:
Thank you all, I am going to try some of these suggestions when I get back to the clients office... Will post results and accept an answer.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now