Start application using batch file




















I'm getting error Windows cannot find the file. Make sure you typed the name correctly, and then try again. SomethingDark I found out why it didn't work. Check the update. Amer Amer 1 1 silver badge 11 11 bronze badges. I know that it works, but please - don't do that. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. For example, if you had Google Chrome installed on your computer and wanted to start the Chrome browser through a batch file, you could use the command below.

The Program Files x86 folder name includes spaces in it. Enclosing the folder name in double quotes tells Windows the spaces are part of the folder name. A batch file can only execute or start another program. Simply put the bat file into the Windows directory, and it will run as administrator. I tried this myself, and it worked:. I think microsoft made as much as they could to prevent batch script to get administrative privileges on their own.

Take a look if it's what you looking for and what you need. If not, let me know and we could adapt your script to make it work. Within the batch file itself there is no way to run as an administrator, however if you launch the batch file from within a. VBS file, you are able to specify a 'runas' parameter.

This will launch your batch file as an administrator, and you can enable or disable the shell display this example hides it as i wanted my program to run in the background without being seen. I actually joined just to answer this, the simplest way by far is to create a shortcut to the program you want to run, then set the shortcut to run as administrator and just call the shortcut from the batch file.

This will run with the settings specified in the shortcut and you could place this shortcut in the same folder as your batch file or just call it from the start menu. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. But, what if you have a number of applications that you use frequently, and only want to choose from a list, a certain combination of applications to open at the same time?

For example, you have a book report due and you need to research the material on the Internet. In this case you want to open Microsoft Word and Firefox. Or, it's time to pay the bills, and you need to open Notepad, Calculator and Microsoft Excel. To do this we can create a batch file with a list of applications. When you run the batch file, a menu will appear that will accept user input from the command line and open the applications that you choosen as shown in above screen shot.

To create the batch file, first, you will want to make a list of applications that you use frequently. For this example, I will select six applications remember they can be any amount and type of applications you want to use :. Next, find the executable path for each application. This can be accomplished by finding the shortcut of the application in the Start Menu and right click on the application icon make sure the Shortcut tab is selected. For Microsoft Office Applications, you will need to look in the folder where Office is installed.

On my computer, the executable path is:. For any application executable that you can not find, use Windows search in XP and Vista to help find the location. Next name the file what ever you want and for now, leave the extension as. Open the file that you created using notepad, then copy and paste the following code. An explanation of the code is listed below :.

Notepad echo 2. Calculator echo 3. Microsoft Word echo 4. Microsoft Excel echo 5. Internet Explorer echo 6. Firefox echo 7. I'm Done echo. I'm Done.



0コメント

  • 1000 / 1000