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

PainlessTorture

Official Best Member
Vista Pro
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 Computer

System One

  • Manufacturer/Model
    Hewlett Packard
    CPU
    3.40Ghz / 2.20Gz Duo Core
    Memory
    2GB / 3GB
    Hard Drives
    160 GB / 160 GB
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 Computers

System One System Two

  • Operating System
    Windows 10 Pro 64-bit
    Manufacturer/Model
    Custom
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
  • Operating System
    Windows 10 Pro
    Manufacturer/Model
    HP Envy Y0F94AV
    CPU
    i7-7500U @ 2.70 GHz
    Memory
    16 GB DDR4-2133
    Graphics card(s)
    NVIDIA GeForce 940MX
    Sound Card
    Conexant ISST Audio
    Monitor(s) Displays
    17.3" UHD IPS touch
    Screen Resolution
    3480 x 2160
    Hard Drives
    512 GB M.2 SSD
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 Computer

System One

  • Manufacturer/Model
    Hewlett Packard
    CPU
    3.40Ghz / 2.20Gz Duo Core
    Memory
    2GB / 3GB
    Hard Drives
    160 GB / 160 GB
You might need to talk to your administrator then to see what he/she can do for you about possibly allowing this.
 

My Computers

System One System Two

  • Operating System
    Windows 10 Pro 64-bit
    Manufacturer/Model
    Custom
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
  • Operating System
    Windows 10 Pro
    Manufacturer/Model
    HP Envy Y0F94AV
    CPU
    i7-7500U @ 2.70 GHz
    Memory
    16 GB DDR4-2133
    Graphics card(s)
    NVIDIA GeForce 940MX
    Sound Card
    Conexant ISST Audio
    Monitor(s) Displays
    17.3" UHD IPS touch
    Screen Resolution
    3480 x 2160
    Hard Drives
    512 GB M.2 SSD
I hope the administrator will allow you.
 

My Computers

System One System Two

  • Operating System
    Windows 10 Pro 64-bit
    Manufacturer/Model
    Custom
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
  • Operating System
    Windows 10 Pro
    Manufacturer/Model
    HP Envy Y0F94AV
    CPU
    i7-7500U @ 2.70 GHz
    Memory
    16 GB DDR4-2133
    Graphics card(s)
    NVIDIA GeForce 940MX
    Sound Card
    Conexant ISST Audio
    Monitor(s) Displays
    17.3" UHD IPS touch
    Screen Resolution
    3480 x 2160
    Hard Drives
    512 GB M.2 SSD
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 Computer

System One

  • Internet Speed
    TERRIBLE, this is the Philippines after all.
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 Computer

System One

  • Manufacturer/Model
    Hewlett Packard
    CPU
    3.40Ghz / 2.20Gz Duo Core
    Memory
    2GB / 3GB
    Hard Drives
    160 GB / 160 GB
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 Computer

System One

  • Internet Speed
    TERRIBLE, this is the Philippines after all.
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 Computer

System One

  • Manufacturer/Model
    Hewlett Packard
    CPU
    3.40Ghz / 2.20Gz Duo Core
    Memory
    2GB / 3GB
    Hard Drives
    160 GB / 160 GB
Although, why did it run a shutdown command? It would have been much more fun to kill the wininit.exe :P

Im not sure :)
I do know that by the time you saw the black box, windows was already shutting down.

Maybe the fun was had when the batch file was set to run at startup.
 

My Computer

System One

  • Internet Speed
    TERRIBLE, this is the Philippines after all.
Although, why did it run a shutdown command? It would have been much more fun to kill the wininit.exe :P

Im not sure :)
I do know that by the time you saw the black box, windows was already shutting down.

Maybe the fun was had when the batch file was set to run at startup.

Its a hobbie of mine to wreak computers via virus'.

Obviously not other peoples computers, I use VM to do it :)

I get quite a bit of fun from it actually. I have never thought of using pre-built utilities to threaten the system. Pretty smart idea.

Well thanks for letting me know how to do it :)
 

My Computer

System One

  • Manufacturer/Model
    Hewlett Packard
    CPU
    3.40Ghz / 2.20Gz Duo Core
    Memory
    2GB / 3GB
    Hard Drives
    160 GB / 160 GB
Back
Top