Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 14th, 2009, 6:04 PM   #1
ellyezr
Newbie
 
Join Date: Jan 2009
Posts: 1
Rep Power: 0 ellyezr is on a distinguished road
Is it possible to make an .exe that acts as a shortcut to another .exe

I want to make an .exe file that shortcuts to
C:\Program Files\EA GAMES\Battlefield 2\BF2.exe" +modPath mods/sandbox"
.

Is it possible to make the script kill one process and then start another?

I am completely new to scripting. This is kind-of what I am looking for, my friend suggest python for this but I don't know what to use, possibly VBScript?

Run .exe
Kills process labeled "unwantedprocess.exe" which can be set to whatever I need to get rid of.
after it kills said process,
Start process in "C:\Program Files\EA GAMES\Battlefield 2\BF2.exe" +modPath mods/sandbox".

I am not sure if it is possible to make a file kill another process with python or any other language.

Bascially the exe does the same as a shortcut with Target: C:\Program Files\EA GAMES\Battlefield 2\BF2.exe" +modPath mods/sandbox and Start In: C:\Program Files\EA GAMES\Battlefield 2\BF2.exe
ellyezr is offline   Reply With Quote
Old Jan 14th, 2009, 6:09 PM   #2
Bensky
Programmer
 
Join Date: Dec 2008
Posts: 30
Rep Power: 0 Bensky is an unknown quantity at this point
Re: Is it possible to make an .exe that acts as a shortcut to another .exe

Hey.

Here's something I wrote in C# .NET a while ago that launches Counter Strike: Condition Zero (with arguments, like you need), and finds other processes using GetProcesses() from the Process class. It then sets the process priority of the other programs to low, and exits. Instead of setting the priority class to low, you could make a call to Kill(), which would kill the process. I'm not sure what your level of experience is with this, ask me if you have any questions.

using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Threading;

namespace CZLauncher
{
    class Program
    {
        static void Main(string[] args)
        {
            bool found = false;
            Process conditionZero = new Process();
            conditionZero.StartInfo.FileName = "C:/Program Files/Steam/Steam.exe";
            conditionZero.StartInfo.Arguments = "-applaunch 80";
            conditionZero.Start();
            Console.WriteLine("--- CS: CZ Launcher by Bensky (aim bugfix) ---\nSearching for hl.exe process...");
            while(!found)
            {
                Process[] pList = Process.GetProcesses();
                for (int i = 0; i < pList.Length; i++)
                    if (pList[i].ProcessName.Equals("hl"))
                    {
                        Console.WriteLine("Found hl.exe process! Setting pClass to Low...");
                        pList[i].PriorityClass = ProcessPriorityClass.Idle;
                        Console.WriteLine("Set hl.exe process to Low.");
                        found = true;
                    }
                    if(pList[i].ProcessName.Equals("Steam")
                    {
                        Console.WriteLine("Found steam.exe process! Setting pClass to Low...");
                        pList[i].PriorityClass = ProcessPriorityClass.Idle;
                        Console.WriteLine("Set steam.exe process to Low.");
                    }
                Thread.Sleep(100);
            }
            Console.WriteLine("Done, exiting...");
        }
    }
}
Bensky is offline   Reply With Quote
Old Jan 14th, 2009, 7:17 PM   #3
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Google / Kitchener
Posts: 4,154
Rep Power: 17 Sane has a spectacular aura aboutSane has a spectacular aura about
Send a message via MSN to Sane
Re: Is it possible to make an .exe that acts as a shortcut to another .exe

Quote:
Originally Posted by ellyezr View Post
I want to make an .exe file that shortcuts to
C:\Program Files\EA GAMES\Battlefield 2\BF2.exe" +modPath mods/sandbox"
.
There's a difference between making a shortcut, and launching an application. I presume you want to launch an application.

Quote:
Originally Posted by ellyezr View Post
Is it possible to make the script kill one process and then start another?
Yes. After all, your Windows "Task Manager" is an example of a program that can kill a process.

Quote:
Originally Posted by ellyezr View Post
I am completely new to scripting. This is kind-of what I am looking for, my friend suggest python for this but I don't know what to use, possibly VBScript?
No, if you came here to use Python, then you will use Python. VBScript is not Python. VBScript is a separate language entirely.

Quote:
Originally Posted by ellyezr View Post
Run .exe
Kills process labeled "unwantedprocess.exe" which can be set to whatever I need to get rid of.
after it kills said process,
Start process in "C:\Program Files\EA GAMES\Battlefield 2\BF2.exe" +modPath mods/sandbox".

I am not sure if it is possible to make a file kill another process with python or any other language.
Of course. If your application is OS-specific to Windows, then you can "import os" and make "os.system()" calls appropriately.

import os
os.system("taskkill ...")
os.system("start ...")

taskkill and start are both Windows OS commands, and are independent of Python. You can look up their usage with Google.
__________________
PFO's Folding@Home Team | Sane's Monthly Algorithms Challenges
Rules | How to Post a Question | How to Post Code

Becoming a good programmer requires foresight of your code's execution.
Becoming an excellent programmer requires foresight of your code's modification.
Sane is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do u make the mousse move? hervens48 C++ 5 May 18th, 2006 3:09 AM
way to make a function execute at time 'x' badbasser98 C++ 10 Apr 5th, 2006 8:14 AM
i need an application to create a shortcut to itself killcity44 Visual Basic 1 Jul 8th, 2005 8:33 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:10 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC