Hide file started through 'run' key in registry - batch-file

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.

Related

How to start c app from desktop with double-click?

I have written one very simple app in C. I know how to run it through Visual studio, but i want to start it from desktop with a double-click. If I double-click on a .exe file made in folder, it does not start. How can I do this?
If you do not wish to modify your code so that it will wait for user input before closing (and there are many reasons that might be inappropriate), you could create a batch file wrapper:
myprog.bat
myprog.exe
pause
Then either you can double click the batch file or create a shortcut to the batch file then edit the shortcut to set the path to the batch file and the path from which to run (so it can find the exe).
That pretty much emulates how Visual Studio runs your code without terminating the window.
Another method you might consider is a batch file such as:
runner.bat
%1
pause
Then you can drag-and-drop your executable onto the runner.bat icon to run it. The advantage being that you don't have to create a new batch file and/or shortcut for every new executable.
Really though this is not a C question, or even a programming question - it is most likely off topic. If your code is ever required to run to completion unattended in a batch file for example, you would not necessarily want to add any interactivity to the program itself.
Your problem is that double clicking on a console app will open a new console window, run the program and then close the window.
VS studio does a trick where it runs the app in a new console window but keeps it open till you press a key.
You can add that same thing yourself - put a getchar() call at the end
Or you can make a bat file to run the app as per Cliffords answer
1st open the code with visual studio code
Run or Build the program
then u will find an executable file where u have saved your code
Open that executable file
but you must have installed mingw installed in your environment
you must compile it first with mingw or like compiler. and start it with by code:
cmd> yourdirectory(e.g Desktop)/ gcc yourcodefile.c your question is available also internet => how-to-compile-c-program

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!

Using a batch file on Desktop to start shortcut on AllUsersDesktop

I use a remote support program to access agent's computers to set them up to work with our dialer.
I use a script via that remote program that adds IE shortcuts to their desktop. To make this script work for any variety of computer setups, the shortcuts are created on the AllUsersDesktop.
I also install a program (called Ventrilo) that creates a shortcut on the specific desktop they are on when I remote into their system.
I would like to add a batch file they can execute that will automatically open the shortcut to Ventrilo and open the IE shortcut on the AllUsersDesktop.
The batch file I have is as follows:
#echo off
start Ventrilo.lnk
start Shortcut.lnk
This opens Ventrilo but not the Shortcut. I am certain it is because the Shortcut is on the AllUsersDesktop, while the shortcut to Ventrilo is not. However, I cannot figure out how to use that start command in conjunction with %AllUserDesktop%
%allusersprofile%\desktop\shortcut.lnk
Type set in a command prompt.
You can start IE by calling start on iexplore, no need to run the shortcut.
start iexplore
Alternatively GoughW's answer should do the trick to.
Make sure you have an end line at the end of your
start shortcut.lnk
in your batch file.

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