cmd windows suddenly minimising to the taskbar - batch-file

The past few days, whenever a cmd window opens (usually via a batch script or vbs file, but if I go to the Search box, type cmd and click on the cmd.exe result, that also does the same thing), the window opens on my desktop but immediately minimises to the taskbar. I want things back the way they were (no idea why the behaviour has changed), so that it remains up on my desktop, in its usual normal window, and I can read it. I am currently having to go down to the taskbar every time to bring it back up (which as I use quite a lot of scripting, is getting very frustrating).
If I launch the script from a shortcut, it will open normally; whereas if I click on the script file itself, it goes to the taskbar. Since many batch or vbs scripts I run are part of a larger one, they are all pointed to the .bat or .vbs script itself, not to a shortcut. For example, this extract from a vbs script, which launches the batch script from the bat file (not a shortcut to that file):
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""C:\Users\Martin\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Batch Files\FS\PF3-XP_ini.bat""")
Set objShell = Nothing
Just to be clear, I have no instruction in the script itself for this to happen and scripts that I have used for years are now all being sent to the taskbar the second they open, instead of remaining in a readable window, as they always have in the past.
Can anyone please help me with this? Thanks.

Yes, true enough. In any case I tracked down the problem just this minute. I suddenly realised what must have happened. Sure enough, I have Windows Manager installed (which remembers window sizes on positions on multiple monitors) and the 'Freeze' option was off. So at some stage over the past few days I had obviously had a cmd window open and minimised it - WM had remembered this so that cmd windows always opened minimised thereafter. Don't know why that didn't occur to me sooner.
Luckily I had thought that this might happen and had made a backup of the WM profile. I just restored it and all is OK again.
Sorry for what in effect was a false alarm!

Related

How to run batch file via task scheduler to route print and keep the DOS window open/command line available to add text

in advance, thank you for any insight you may be able to offer. i know that there is a very similar post to my scenario and i have tried all variations of the answer but cannot get it to work for me as per the initial or edited instructions. in order to circumvent the uac nags, i am running windows 7 (64 bit) and trying to run a batch file to simply 'route print cmd /k' via task scheduler and desktop shortcut but i want the DOS window to remain open and allow me to continue typing into it. when i execute the actual file, it runs as desired, however when it runs via task scheduler, the dos window closes immediately. to no avail, i have tried multiple things such as changing the 'program/script' field from C:\location\batchfilename.bat to just cmd and inputting the various arguments including cmd /k or /k or /k C:\location\batchfilename.bat to the task's 'add arguments' field and/or the batch script itself. although i do not want pause as it would close the window after pressing any key, i have also tried it in the script itself and the arguments field but it too does not keep the dos window open when running as scheduled task. nothing seems to work - your help is greatly appreciated!

Hide file started through 'run' key in registry

I have created a run key in the registry for a simple batch file which copies the ip of a server I play COD on to the clipboard, so I don't have to open my browser to get it.
However, every time I log on, it displays the annoying CMD which does the copying.
Is there a way to hide the program started via Registry, so it doesn't show up unless task manager is opened? I prefer this as a solution as opposed to another method.
Thanks
You can use a vbs file to launch a batch file with the window hidden so that it is only visible in task manager.
Visit: http://www.instructables.com/id/Start-a-batch-file-completely-hidden/ for a brief instructable.
The code is basically:
CreateObject("Wscript.Shell").Run """" & "C:\batch-file.bat" & """", 0, False
You can compile it with a program called "advanced bat to exe". Google it, it's free.
Once you compile the script, there is an option that says "launch invisible". This is what you want.
I think this is the best method, as there's only one file. It's also probably the easiest.

Batch files/Windows 7 - Open UAC prompt minimized on purpose

There are many users struggling with UAC prompts opening in background instead of foreground. Well, I want to do exactly the opposite, ie having the UAC prompt flash on the taskbar and waiting for my attention instead of dimming my whole screen and messing my workflow.
Here's my setup: I'm working on a Win7 x64 machine, and I placed this link in my Startup folder:
C:\CLUs\chp.exe "apps.bat"
chp.exe is an utility that loads batch files without showing the command prompt.
apps.bat calls several unelevated programs (easier to manage apps in this way rather than putting a bunch of links in Startup). The last line of such bat is
elevate chp "elevapps.bat"
elevate.exe is an utility that, as the name says, elevates whatever is called with issuing an UAC prompt. And, clearly, elevapps.bat contains another bunch of programs that require admin rights to start properly.
Now, for a number of reasons I'd like the UAC prompt to start minimized/in background. Ie, once I've logged in Windows, all I want to see is the taskbar containing the flashing icon of the UAC, but no dimmed screen.
Is this possible with batch files? All I know is that UAC "smartly" detects whether it is stealing focus or not and (doesn't) show up accordingly. And clearly during the startup there's nothing to steal focus from, so looks like I'm having no luck. However it also seems that badly coded software (namely not assigning HWNDs somewhere, see here and here) precisely produces this effect. Is there a way to reproduce this "bug" (I'd call it a feature, in my case) with some code in a batch file? Also using a third party utility would be fine, however I'm not a programmer.
I solved the problem by using winapiexec.exe, an utility that allows (as per site) to run WinAPI functions through command line parameters.
winapiexec shell32.dll#ShellExecuteW NULL "runas" "chp" "elevapps.bat" NULL 7

Batch Scripts Will not run on some Windows 7 systems

Any ideas why bat files don't run in some cases?
I have written an interactive batch script (also run as an exe) works on THOUSANDS of systems, HOWEVER, a small subset of systems will NOT launch the script. They open a black box window and then close the script without giving the user the bat menu. I tried the bat file association registry reset which ensures that .bat file association is correct but that didn't help.
What I have tried: bat registry fix (.reg file)
(which didn't seem to help, the script starts but doesn't run)
(I also tested a VERY basic script that printed Hello world which also didn't work)
Thanks everyone for your help. What I found out was:
(1) Reset the command prompt:
http://social.technet.microsoft.com/Forums/windows/en-US/0a74090e-53ce-4642-8dad-0523bfd6c8a2/cant-run-bat-batch-files?forum=w7itproui
(which did not work for me)
(2) In a command prompt I had the users type 'set path' which showed that they were missing /windows/system32/ for one user. So far I had one user put it in and it fixed it. One other user had %systemroot%/system32 which I will have them try adding the path the other way to see if it fixes it. Next I will see if I can just add that to the script.

Remove the close option on a batch file with a command, is it possible?

I was just wondering if there is a code that can remove the "close" button on a batch file. (The minimize and expand buttons isn't important so it is ok if they will be disabled or will stay enabled) That is all. I can't seem to find any answer anywhere.
Thanks.
A batch file is nothing more that a script that another program must execute.
When you double-click a .bat file in Explorer, cmd.exe launches and "opens" the file, running the script. So your question is: can you remove the close button from cmd.exe? Good luck.
You don't want to be doing that. You should make your script NOT show a window to begin with.
If the window is shown, a user can always Ctrl + C to stop the script mid-stream.
There is a number of ways you can make the window hidden (also called "running a script silently"). See the following links:
Run a completely hidden batch file
Solved: HowTo run a batch file without it showing
Eric Helps
Or just google for "batch file silent" or "batch file hide console".
Just a side note: if you have seen this behavior before, chances are that it is not a batch file, but another programming language, and probably not using cmd.exe. C# can let you make a console program app which you can manipulate the title, but even still you cannot change the control buttons on the window. It is simply not within c# or a batch file's scope.

Resources