Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Vista Forums > General Discussion

Vista - Make a command prompt run a command as soon as it opens?

Reply
 
Old 11-16-2008   #1 (permalink)


Windows Vista™ Ultimate x64
 
 

Make a command prompt run a command as soon as it opens?

Hey guys.

Ive been trying to figure out how to make a command prompt run a command line as soon as the box comes up.

I need this to happen all from one command line. A command prompt needs to open with "echo hi" being ran as a command line.

Any ideas?
Thanks

My System SpecsSystem Spec
Old 11-16-2008   #2 (permalink)


Vista x64 Ultimate SP2, Windows 7 Ultimate x64
 
 

Re: Make a command prompt run a command as soon as it opens?

Hello Fmjc001,

You could create a BAT file for this. Just type in the commands into a TXT file, then rename the file extension to BAT. When you run the BAT file it will run the commands in a command prompt automatically.

Hope this helps,
Shawn
My System SpecsSystem Spec
Old 11-16-2008   #3 (permalink)


Windows Vista™ Ultimate x64
 
 

Re: Make a command prompt run a command as soon as it opens?

Quote  Quote: Originally Posted by Brink View Post
Hello Fmjc001,

You could create a BAT file for this. Just type in the commands into a TXT file, then rename the file extension to BAT. When you run the BAT file it will run the commands in a command prompt automatically.

Hope this helps,
Shawn
Thanks for the reply Shawn. Unfortunity I cant use a bat because of a software restriction policy enforced on the system
My System SpecsSystem Spec
Old 11-16-2008   #4 (permalink)


Vista x64 Ultimate SP2, Windows 7 Ultimate x64
 
 

Re: Make a command prompt run a command as soon as it opens?

You might need to talk to your administrator then to see what he/she can do for you about possibly allowing this.
My System SpecsSystem Spec
Old 11-16-2008   #5 (permalink)


Windows Vista™ Ultimate x64
 
 

Re: Make a command prompt run a command as soon as it opens?

Quote  Quote: Originally Posted by Brink View Post
You might need to talk to your administrator then to see what he/she can do for you about possibly allowing this.
OK, Thanks.
My System SpecsSystem Spec
Old 11-17-2008   #6 (permalink)


Vista x64 Ultimate SP2, Windows 7 Ultimate x64
 
 

Re: Make a command prompt run a command as soon as it opens?

I hope the administrator will allow you.
My System SpecsSystem Spec
Old 11-17-2008   #7 (permalink)


Premium 32bit SP1
 
 

Re: Make a command prompt run a command as soon as it opens?

This reminds me of a "virus" that was popular before.
Whenever a command prompt was opened, even in safe mode, cmd.exe would exicute a bat file, causing Windows to shut down.

Here is how its done. (I trust this will be used for good, not evil.)

First create a bat file containing the command you wish to run.
Then, in the registry, navigate to
HKEY_CURRENT_USER\Software\Microsoft\Command Processor
and create a string named autorun and give it the value of where your bat file is located.
For example C:\mybat.bat

To remove this functionality, delete the autorun string in the registry.
My System SpecsSystem Spec
Old 11-17-2008   #8 (permalink)


Windows Vista™ Ultimate x64
 
 

Re: Make a command prompt run a command as soon as it opens?

Quote  Quote: Originally Posted by validation View Post
This reminds me of a "virus" that was popular before.
Whenever a command prompt was opened, even in safe mode, cmd.exe would exicute a bat file, causing Windows to shut down.

Here is how its done. (I trust this will be used for good, not evil.)

First create a bat file containing the command you wish to run.
Then, in the registry, navigate to
HKEY_CURRENT_USER\Software\Microsoft\Command Processor
and create a string named autorun and give it the value of where your bat file is located.
For example C:\mybat.bat

To remove this functionality, delete the autorun string in the registry.
Will this run the command line on every command prompt opened?
My System SpecsSystem Spec
Old 11-17-2008   #9 (permalink)


Premium 32bit SP1
 
 

Re: Make a command prompt run a command as soon as it opens?

Quote  Quote: Originally Posted by Fmjc001 View Post
Will this run the command line on every command prompt opened?
From what I have experienced, yes.
It does not matter how many you open, or the circumstances that started cmd.exe. Meaning that even if the command prompt was launched directly, through another program, from a shortcut or through the run dialog, it will always run whatever was put in the registry.
My System SpecsSystem Spec
Old 11-17-2008   #10 (permalink)


Windows Vista™ Ultimate x64
 
 

Re: Make a command prompt run a command as soon as it opens?

Quote  Quote: Originally Posted by validation View Post
Quote  Quote: Originally Posted by Fmjc001 View Post
Will this run the command line on every command prompt opened?
From what I have experienced, yes.
It does not matter how many you open, or the circumstances that started cmd.exe. Meaning that even if the command prompt was launched directly, through another program, from a shortcut or through the run dialog, it will always run whatever was put in the registry.
Yeah, I can see what that could be a problem....

Although, why did it run a shutdown command? It would have been much more fun to kill the wininit.exe :P
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How to make a batch file on starting and stopping services from command prompt ? General Discussion
Command prompt "COPY" command not working in brand new Windows Vis Vista file management
DVD Command Prompt Vista installation & setup
Vista RC1 install error, stops 1/2 way and opens command a prompt Vista installation & setup
Vista RC1 install error, stops 1/2 way and opens command a prompt Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

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