Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Execute program without tying up CMD

Reply
Thread Tools Display Modes

Execute program without tying up CMD

 
 
Synapse Syndrome [KGB]
Guest
Posts: n/a

 
      04-09-2009

I am trying to make a .cmd script execute a program (a text editor), and
then do other stuff, but it will not continue until that program has been
closed.

I have tried using the CMD command itself, with the /s switch, but that is
not working in any way that I understand.

How can I do this?

Cheers

ss.


 
Reply With Quote
 
 
 
 
Pegasus [MVP]
Guest
Posts: n/a

 
      04-09-2009

"Synapse Syndrome [KGB]" <> wrote in message
news:...
>
> I am trying to make a .cmd script execute a program (a text editor), and
> then do other stuff, but it will not continue until that program has been
> closed.
>
> I have tried using the CMD command itself, with the /s switch, but that is
> not working in any way that I understand.
>
> How can I do this?
>
> Cheers
>
> ss.


Use the Start command, e.g.

start /b notepad.exe

Type start /? to see the various switches.


 
Reply With Quote
 
Synapse Syndrome [KGB]
Guest
Posts: n/a

 
      04-09-2009
Pegasus [MVP] <> wrote:
>
>> I am trying to make a .cmd script execute a program (a text editor), and
>> then do other stuff, but it will not continue until that program has
>> been closed.
>>
>> I have tried using the CMD command itself, with the /s switch, but
>> that is not working in any way that I understand.
>>
>> How can I do this?
>>
>> Cheers
>>

>
> Use the Start command, e.g.
>
> start /b notepad.exe
>
> Type start /? to see the various switches.



Ah, thanks. I should have of that. I use...

start .

....all the time.

Cheers

ss.


 
Reply With Quote
 
Synapse Syndrome [KGB]
Guest
Posts: n/a

 
      04-10-2009
Pegasus [MVP] <> wrote:
>>
>> I am trying to make a .cmd script execute a program (a text editor), and
>> then do other stuff, but it will not continue until that program has
>> been closed.
>>
>> I have tried using the CMD command itself, with the /s switch, but
>> that is not working in any way that I understand.
>>
>> How can I do this?
>>
>> Cheers

>
> Use the Start command, e.g.
>
> start /b notepad.exe
>
> Type start /? to see the various switches.


Hello again

I still cannot get it to work with the particular text editor that I am
using. Something weird is going on.

start /b /i "%programfiles%\JGsoft\EditPadPro6\EditPadPro. exe" "%1"

I am using the /i switch because it is being run from a CMD instance which
is RUNAS adminitrator, but I do not think that this has anything to do with
it not working, as I tried with the current environment as well.

ss.


 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a

 
      04-10-2009

"Synapse Syndrome [KGB]" <> wrote in message
news:...
> Pegasus [MVP] <> wrote:
>>>
>>> I am trying to make a .cmd script execute a program (a text editor), and
>>> then do other stuff, but it will not continue until that program has
>>> been closed.
>>>
>>> I have tried using the CMD command itself, with the /s switch, but
>>> that is not working in any way that I understand.
>>>
>>> How can I do this?
>>>
>>> Cheers

>>
>> Use the Start command, e.g.
>>
>> start /b notepad.exe
>>
>> Type start /? to see the various switches.

>
> Hello again
>
> I still cannot get it to work with the particular text editor that I am
> using. Something weird is going on.
>
> start /b /i "%programfiles%\JGsoft\EditPadPro6\EditPadPro. exe" "%1"
>
> I am using the /i switch because it is being run from a CMD instance which
> is RUNAS adminitrator, but I do not think that this has anything to do
> with it not working, as I tried with the current environment as well.
>
> ss.


Since the path to your executable contains spaces, you MUST use the "Title"
parameter:

start /b /i "Synapse's App"
"%programfiles%\JGsoft\EditPadPro6\EditPadPro. exe" "%1"


 
Reply With Quote
 
Al Dunbar
Guest
Posts: n/a

 
      04-11-2009

"Pegasus [MVP]" <> wrote in message
news:...
>
> "Synapse Syndrome [KGB]" <> wrote in message
> news:...
>> Pegasus [MVP] <> wrote:
>>>>
>>>> I am trying to make a .cmd script execute a program (a text editor),
>>>> and then do other stuff, but it will not continue until that program
>>>> has
>>>> been closed.
>>>>
>>>> I have tried using the CMD command itself, with the /s switch, but
>>>> that is not working in any way that I understand.
>>>>
>>>> How can I do this?
>>>>
>>>> Cheers
>>>
>>> Use the Start command, e.g.
>>>
>>> start /b notepad.exe
>>>
>>> Type start /? to see the various switches.

>>
>> Hello again
>>
>> I still cannot get it to work with the particular text editor that I am
>> using. Something weird is going on.
>>
>> start /b /i "%programfiles%\JGsoft\EditPadPro6\EditPadPro. exe" "%1"
>>
>> I am using the /i switch because it is being run from a CMD instance
>> which is RUNAS adminitrator, but I do not think that this has anything to
>> do with it not working, as I tried with the current environment as well.
>>
>> ss.

>
> Since the path to your executable contains spaces, you MUST use the
> "Title" parameter:


Not exactly. The "title" parameter is required when the pathname of the
executable is contained within double quotes. The quotes are only required
when the executable pathname contains spaces, but they are optional and
always allowed. In fact, one might include them when the pathname is
determined at runtime, in which case one might not know in advance whether
or not spaces are involved.

If that seems an obtuse explanation, look at it from the point of view of
the start command itself: if the first parameter starts with a double quote,
it must be the "title" parameter, in which case executable is given by the
second parameter. Some examples:

these are OK:
start notepad.exe test.cmd
start "" "notepad.exe" test.cmd
start "" notepad.exe test.cmd
this is wrong:
start "notepad.exe" test.cmd

Actually, that is a completely valid command, it just does something you
might not expect. It starts a batch file with the title argument set to
"notepad.exe".

My suggestion to avoid such a gaffe is to always include a title and always
enclose the executable in quotes. If the title is not used for any purpose
by the executable, just give it as "".

> start /b /i "Synapse's App"
> "%programfiles%\JGsoft\EditPadPro6\EditPadPro. exe" "%1"


Note that if the first parameter to the batch file is given enclosed in
quotes (i.e. "file to edit.txt" the above command will pass the name to the
executable as ""file to edit.txt"". The simplest fix is to use this syntax:

> start /b /i "Synapse's App"
> "%programfiles%\JGsoft\EditPadPro6\EditPadPro. exe" "%~1"


The "~" will strip leading/trailing double quotes, but only if the are
present.

/Al


 
Reply With Quote
 
 
 
Reply

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Execute application's exe and perform changes in Program Files - V Abhi Windows Vista General Discussion 6 02-01-2008 12:28 PM
I Can't Execute a Program Because of OS Language Issues Intoeverything90 Windows Media Center 1 11-05-2006 06:57 AM
Cannot execute a program error after installing WSUS Abraham Update Services 1 06-09-2006 10:32 PM
Re: how to logon with and execute a program Robert Cohen Scripting 1 01-21-2004 09:25 PM
Re: how to logon with and execute a program Ray at Scripting 0 01-21-2004 08:28 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59