Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Hide the command prompt windows


  • Please log in to reply

#1
Michael

Michael

    Retired Staff

  • Retired Staff
  • 1,869 posts
I am runing a .bat file and I don't what it to desplay the command prompt window while runing, is there a what to hide it. Could I make a shortcut to it that has some switch in it that hides it. It is not that important but it bothers me having it apear when it dose not need to.
  • 0

Advertisements


#2
timinator

timinator

    Member

  • Member
  • PipPip
  • 18 posts
If you create a shortcut to the batch file, you can set the properties of the shortcut to run the batch file in a minimized window instead of using the default setting of "Normal window".

If you want it completely hidden, then try using scripting:
[urlhttp://www.microsoft.com/technet/scriptcenter/scripts/os/process/procthd/pcthvb02.mspx[/url]

Modify the sample script to run something like "cmd.exe /c abc.bat" instead (with abc.bat replaced with the actual filename).
  • 0

#3
Michael

Michael

    Retired Staff

  • Topic Starter
  • Retired Staff
  • 1,869 posts
What type of file should I save the script as, I am stilll learning all this stuf and not very good at it yet.
  • 0

#4
timinator

timinator

    Member

  • Member
  • PipPip
  • 18 posts
"vbs"
  • 0

#5
Michael

Michael

    Retired Staff

  • Topic Starter
  • Retired Staff
  • 1,869 posts
That is just what I wanted, when the script runs the .bat file it dose not show up.
  • 0

#6
timinator

timinator

    Member

  • Member
  • PipPip
  • 18 posts
A little warning: in case you hadn't already noticed, the current directory may not be the directory containing the script file (on my system, when using a script like that, the current directory is c:\windows\system32), though that can be changed by specifying a directory instead of the "null" on the line that calls objProcess.Create.

Here's another way to do it, using JScript (the sample mentioned earlier uses VBScript; this could be done in VBScript too, but as a matter of personal preference I use JScript instead)

var WindowStyle_Hidden = 0
var objShell = WScript.CreateObject("WScript.Shell")
var result = objShell.Run("cmd.exe /c abc.bat", WindowStyle_Hidden)


If you want to try this, save it to a file with a .js extension.
  • 0

#7
Michael

Michael

    Retired Staff

  • Topic Starter
  • Retired Staff
  • 1,869 posts
I worked that out, so I typed in the full path to the file that I wan't to run.

Since you seam to know about writing scripts can you answer this question. I have this .bat file that when run it asks "Are you sure you wan't to add the information in (where the .reg file is) to the registry? and under this it has the two buttons that say "Yes" and "No" every time I want to "click" yes (why else would I run the .bat file) How can I make a .vbs file that dose this with out the user imput. Also after pressing yes it comes up with "Information in (where the .reg file is) has been successfully entered into the registry" and under that is the OK button and I want it to automaticly "click" this as well. Thanks very much for any help.
  • 0

#8
timinator

timinator

    Member

  • Member
  • PipPip
  • 18 posts
Try adding "/s" to the regedit command line.

http://support.micro...=kb;en-us;82821
  • 0

#9
RAz

RAz

    Member

  • Member
  • PipPip
  • 69 posts
hmm
and what are you exactly trying to create? a virus?

such things should not be encouraged on public forums...
  • 0

#10
Michael

Michael

    Retired Staff

  • Topic Starter
  • Retired Staff
  • 1,869 posts
No, thouth I thought I would get that question about this. I am just making a set of .bat and now .vbs files that do things that I have got sick of doing manualy. one of the first that I did was I have this program that runs these servises all the time and take up a fair bit of memory so the .bat files and the .vbs files turn them on and and when the program is finished back off again. And of coures the .bat files put up annoying command prompt and they look messey.

The other aim it to learn the basics of programing, that is why I started doing this in the first place is made the thing that I wrote usefull to me.

I know that I could make a virus but I see no point in that at all, the people that do have a very weird sence of fun. Do you think that I would make thing harder than they already are for the people that help here (that includes me).
  • 0

Advertisements


#11
RAz

RAz

    Member

  • Member
  • PipPip
  • 69 posts
well this information could be used by other people ... so i think it shouldn't be discussed on the forum... you should ask for a reply via PM next time...
  • 0

#12
Michael

Michael

    Retired Staff

  • Topic Starter
  • Retired Staff
  • 1,869 posts
Do you want me to get someone to remove it? I don't need it any more.
  • 0

#13
Michael

Michael

    Retired Staff

  • Topic Starter
  • Retired Staff
  • 1,869 posts
Just a question, just yesterday all .vbs and .js files that I have made stoped working, would there be a reason for this? :tazz:
  • 0

#14
timinator

timinator

    Member

  • Member
  • PipPip
  • 18 posts
Saying that something isn't working isn't very helpful without further details. Not working in what way? Do you see an error message?

Suggestion: un-hide the window temporarily (if you haven't tried that already); there may be error information available that you haven't seen. If one of the scripts is still based on the VBScript example mentioned earlier, then to use a normal window set objConfig.ShowWindow to 1 instead of HIDDEN_WINDOW.
  • 0

#15
Michael

Michael

    Retired Staff

  • Topic Starter
  • Retired Staff
  • 1,869 posts
Sorry I was very fustrated and and not think clearly. You see the think that I what to hide works but not the .vbs files (all so played aroud with other ones on my computer and they did not work either)
It comes up with a windows called "Windows Script Host"

Script: (what ever one that I am trying to run)
Line: 4 (with the ones that I made it is all ways this line)
char: 1
Error: The remost server machine dose not exits of is unavailable: 'GetObject'
Code; 800A01CE
Source: Microsoft VBScript runtime error

Hope this helps!
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP