Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

CMD: Pass more commands to a single shell !

- - - - -

  • Please log in to reply
8 replies to this topic

#1
Caml Light

Caml Light

    Junior

  • Member
  • Pip
  • 85 posts
Hi guys, if i do this:

WIN+R -> cmd /k echo Hello -> ENTER
WIN+R -> cmd /k echo World -> ENTER

I'll have 2 different CMD shell windows: the first displays "Hello", while the second "World".

Do you know if is it possible to launch the second command in the same CMD shell window of the first one, to have:

Hello
World
_

Thank you in advance

Edited by Caml Light, 01 November 2012 - 08:31 PM.



How to remove advertisement from MSFN

#2
5eraph

5eraph

    Update Packrat

  • MSFN Sponsor
  • 1,149 posts
  • OS:XP Pro x64
  • Country: Country Flag

Donator

You could use the ampersand (&) to pass more than one command per line.

cmd /k echo Hello &echo World


#3
Caml Light

Caml Light

    Junior

  • Member
  • Pip
  • 85 posts
Yes, that works launching a single instance of cmd.exe. But does exists a way to do exactly what i wrote?

#4
5eraph

5eraph

    Update Packrat

  • MSFN Sponsor
  • 1,149 posts
  • OS:XP Pro x64
  • Country: Country Flag

Donator

If there is, I don't know it.

#5
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,205 posts
  • OS:none specified
  • Country: Country Flag

Yes, that works launching a single instance of cmd.exe. But does exists a way to do exactly what i wrote?

I am failing to see the difference between what you initially asked and the result of what was suggested, can you try expanding on what you want to achieve? :unsure:

Additionally, I presume that your actual GOAL is NOT that of having one or more CMD.EXE windows echoing to screen "Hello World" :w00t: , please do state the actual GOAL, there might be different ways to achieve that.

Be aware of the risk of slipping on a chocolate covered banana :ph34r: :
http://homepage.ntlw...red-banana.html

jaclaz

#6
Caml Light

Caml Light

    Junior

  • Member
  • Pip
  • 85 posts
ok... i'll try to explain better:

Imagine to have a CMD shell window already opened. Is it possible to pass it some commands, not writing them into that shell but from WIN+R?

#7
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,205 posts
  • OS:none specified
  • Country: Country Flag

ok... i'll try to explain better:

Imagine to have a CMD shell window already opened. Is it possible to pass it some commands, not writing them into that shell but from WIN+R?

Win+R simply opens the "Run" dialog/popup.
In it you have to type some commands.
You can use some tool (like Nircmd):
http://www.nirsoft.n...ils/nircmd.html
to set focus to the already active CMD window and paste/execute in it some command.

This still seems completely unlike being a GOAL (or if it is a goal, it appears like a senseless one :ph34r: ).
BTW, you seem like having a tradition of being reluctant in providing the actual scope of what you are asking for, posting instead "vague" or "generic" examples, which everytime need some back and forth rounds of questions to actually get what the actual question is about. (and hopefully provide an appropriate solution/answer/advice)

jaclaz

#8
Caml Light

Caml Light

    Junior

  • Member
  • Pip
  • 85 posts
Thank you jaclaz, the actual scope of my question is written in the previous posts. My GOAL is exactly it: To pass to an opened cmd shell some commands written from the "Run" prompt.

Alternatively, instead to use the "Run" prompt, i also can use a cmd batch script that send commands to the opened cmd shell. If i run a common batch, it will open a new cmd shell window.

#9
5eraph

5eraph

    Update Packrat

  • MSFN Sponsor
  • 1,149 posts
  • OS:XP Pro x64
  • Country: Country Flag

Donator

"Why?" or "To what end?" "What purpose..." does reusing a CMD window serve? Why not just include the command in a batch file?

If you want to run a batch script within a batch script, you can always CALL it without opening a new CMD window.

Edited by 5eraph, 02 November 2012 - 04:37 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN