Jump to content

Welcome to Geeks to Go - Register now for FREE
Geeks To Go is a helpful hub, where thousands of friendly volunteers serve up answers and support. Get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message and all ads will be removed once you have signed in.
Create an Account Login to Account

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

Advertisement


#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

  • 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

  • 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

  • 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

  • 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
<

Advertisement


#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

  • 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

  • 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

  • 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

Advertisement




Similar Topics: Hide the command prompt windows     x


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users

As Featured On:

featured