• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Command windows opening behind other windows

Joined
May 27, 2008
Messages
3,577 (1.01/day)
Likes
533
Location
Huddersfield, uk
Processor E8200
Motherboard Asus P5KC
Cooling cooler master hyper tx3, 2x 120mm, 1x 80mm
Memory 4 GB DDR3 OCZ Black Edition
Video Card(s) Gigabyte HD 2600xt silent pipe II
Storage 500GB WD Sata / 60 GB Samsung IDE
Display(s) 20" samusng LCD, gaming at 1680 x 1050
Case some old amd thing
Audio Device(s) onboard
Power Supply 650W
Software Windows 8.1, with 'start is back' obviously
Benchmark Scores It boots whilst im still young so im pleased with that.
#1
Hi all,

Hopefully a quick one here.

Ive made a small application to poll TeamCity build monitor take data about current and past builds and store them in a data base. Its only a very small application and im using windows task scheduler to run it every five minuets. Its working grand and does everything its meant to however when it runs it open a command window. Im not displaying anything nor taking user input and its finished and closed in under half a minuet but it opens on top of any windows I already have open. Control is still focused on the window I was working in before the command window opened. What id like to know is there a way within either task scheduler or something I can programme within the application to either stop the command window opening up but the application still run as its not needed or to make it automatically open behind all other open windows?

Thanks all
 

newtekie1

Semi-Retired Folder
Joined
Nov 22, 2005
Messages
24,419 (5.50/day)
Likes
10,556
Location
Indiana, USA
Processor Intel Core i7 8700K@4.8GHz(Quick and dirty)
Motherboard AsRock Z370 Taichi
Cooling Corsair H110i GTX
Memory 32GB Corsair DDR4-3000
Video Card(s) PNY XLR8 GTX1060 6GB
Storage 480GB Crucial MX200 + 2TB Seagate Solid State Hybrid Drive with 128GB OCZ Synapse SSD Cache
Display(s) QNIX QX2710 1440p@120Hz
Case Fractal Design Define S
Audio Device(s) Onboard is good enough for me
Power Supply Corsair HX850
Software Windows 10 Pro x64
#2
How is your program being called? Does the program run inside the command prompt?

If so you can create the scheduled task pointing to cmd.exe and use the following arguments

/c start /min [yourprogram] ^& exit
 

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
21,079 (6.22/day)
Likes
10,206
Location
IA, USA
System Name BY-2015
Processor Intel Core i7-6700K (4 x 4.00 GHz) w/ HT and Turbo on
Motherboard MSI Z170A GAMING M7
Cooling Scythe Kotetsu
Memory 2 x Kingston HyperX DDR4-2133 8 GiB
Video Card(s) PowerColor PCS+ 390 8 GiB DVI + HDMI
Storage Crucial MX300 275 GB, Seagate 6 TB 7200 RPM
Display(s) Samsung SyncMaster T240 24" LCD (1920x1200 HDMI) + Samsung SyncMaster 906BW 19" LCD (1440x900 DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay
Audio Device(s) Realtek Onboard, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse SteelSeries Sensei RAW
Keyboard Tesoro Excalibur
Software Windows 10 Pro 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
#3
If it is a .NET program, you need to create a ProcessStartInfo instance and set CreateNoWindow to false, WindowStyle to hidden, and set UseShellExecute to false. Pass it to Process.Start(startinfo).

If using something other than .NET, use cmd.exe.

If you want to just set focus, use SetFocus in user32.dll. Examples here:
http://www.pinvoke.net/default.aspx/user32.setfocus

You can also hide a window of another application using user32.dll's showwindow command (set it to false):
http://www.pinvoke.net/default.aspx/user32.showwindow
 
Last edited:
Joined
May 27, 2008
Messages
3,577 (1.01/day)
Likes
533
Location
Huddersfield, uk
Processor E8200
Motherboard Asus P5KC
Cooling cooler master hyper tx3, 2x 120mm, 1x 80mm
Memory 4 GB DDR3 OCZ Black Edition
Video Card(s) Gigabyte HD 2600xt silent pipe II
Storage 500GB WD Sata / 60 GB Samsung IDE
Display(s) 20" samusng LCD, gaming at 1680 x 1050
Case some old amd thing
Audio Device(s) onboard
Power Supply 650W
Software Windows 8.1, with 'start is back' obviously
Benchmark Scores It boots whilst im still young so im pleased with that.
#4
Thanks all the cmd.exe method worked a treat