Jump to content

Running a Batch file without Command Prompt Window?


Recommended Posts

Hi Everyone

I was wondering, I don't know if its possible or not, but I'm using a .bat that executes an .exe with this:

START "C:\WINDOWS\PROGRAM.EXE"

EXIT

this opens up a cmd windows and close it at the same time.

Is there a way to run the ".bat" without having the cmd window open at all?

Thanks in advance

Link to comment
Share on other sites


If you were to give us a better explanation of your problem we may be better suited to answer you accordingly.

  • Why are you running a .bat?
    Since the emergence of Windows NT Operating System, .cmd has been the default.
  • When and in what circumstances is it being run?
    Whatever executes the script may be able to directly execute 'PROGRAM.EXE'
  • Are you sure that you have provided the proper executable file path and name?
    Since \WINDOWS is in %PATH%, the following may be all that is required
    @START PROGRAM


Link to comment
Share on other sites

Thank for both reply s

What I'm trying to do is a portable link, where I can execute an exe from an USB no matter what letter windows gives it.

For example:

@echo off

START \Apps\InfraRecorder\InfraRecorder.exe

Exit

This would open up Infra Recorder, instead of browsing to it to open it.

Thanks.

Link to comment
Share on other sites

The .bat file is store in my USB and the application is located in a folder call apps. By portable link i mean been able to execute the .bat file on any pc regardless of the drive's letter assign by Windows.

In a shortcut you would have "F:\Apps\InfraRecorder\InfraRecorder.exe", but if you plug in this flash drive to another computer this shortcut wouldn't work. But with the .bat file you don't have that problem because it only has "\Apps\InfraRecorder\InfraRecorder.exe" which makes this shortcut portable. You plug this flash drive into any PC and the links works.

Does this makes things clearer?

Link to comment
Share on other sites

This relative path functionality has for a long time been on many peoples wishlist for shortcuts.

There is a workaround which I could suggest in your case.

Use the following as the target to your shortcut

*:\Apps\InfraRecorder\InfraRecorder.exe

The trick to making this work however is that the shortcut must be made read-only in order that the asterisk is not replaced with the actual drive letter on running.

I have prepared one for you already in the attachment below.

InfraRecorder.zip

Link to comment
Share on other sites

The trick to making this work however is that the shortcut must be made read-only in order that the asterisk is not replaced with the actual drive letter on running.

Thanks but the shortcut you gave me didn't work is there something more i need to do?

If I get it right you will have a number of batch files in the root of the USB stick that you have to run, one for each app.
or Portable Apps Menu - http://portableapps.com/

I'm only running three applications, i rather have three shortcuts then to install a menu.

Link to comment
Share on other sites

The trick to making this work however is that the shortcut must be made read-only in order that the asterisk is not replaced with the actual drive letter on running.

Thanks but the shortcut you gave me didn't work is there something more i need to do?

On testing it appears that the Shortcut format is different across versions of Windows, the version I produced was created and tested in Vista. Creating the shortcut in Windows 2000 appeared not to work at all! You could try it in XP, however I'm doubting that it would create a universally working shortcut too!

Another alternative would be to run your batch file using a window hiding application.

Link to comment
Share on other sites

I have a USB key with a bunch of programs on it (in various directories), and I have a bunch of CMD files in the root to quickly run these programs. If this is what you are looking for the solution is simple.

Lets say you want a batch file to execute a program on the USB stick located in (USB Drive):\Applications\Everest\Everest.exe

Create a CMD (or BAT) file on the root of your USB drive with the following:

@%~dp0Applications\Everest\Everest.exe

That's all you need. Works on all versions of Windows and no matter what drive letter the USB disk was assigned. The %~dp0 references the relative path of the batch file. Note, the above command only works in batch files, if you enter it in to the command prompt directly (for testing) it doesn't work that way.

You may also want to to use the start command in the batch file:

@START "Everest" /SEPARATE "%~dp0Applications\Everest\Everest.exe"

EXIT

That way the command prompt window will close after flashing temporarily.

Edited by Noise
Link to comment
Share on other sites

Create a CMD (or BAT) file on the root of your USB drive with the following:

@%~dp0Applications\Everest\Everest.exe

They already use a method similar to this, however they dislike the flash of the cmd window!
Link to comment
Share on other sites

....and we are back to square ... #2 :thumbup :

Another alternative would be to run your batch file using a window hiding application.

Some listed here:

http://www.msfn.org/board/hide-ms-dos-windows-t100463.html

Please be aware that some antivirii may detect some of these as a potential threat.

jaclaz

Edited by jaclaz
Link to comment
Share on other sites

Just to better explain the vbs idea mentioned by gunsmokingman, you can create one like this:

InfraRecorder.vbs

CreateObject("Wscript.Shell").Run (CreateObject("Scripting.FileSystemObject") _
.GetParentFolderName(WScript.ScriptFullName) &_
"\Apps\InfraRecorder\InfraRecorder.exe"), 1, True

Just place the vbs in the root of your USB drive and run it to start you application.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...