Page 1 of 1

~ Hide Dos Console ~

Posted: 11 Sep 2012 20:09
by Dos_Probie
There are times when you don't need to see your console when running a file,
Here's a little .vbs script to hide your dos console, There are other 3rd party
files out there like cmdow but Microsoft Essentials, AVG etc. gives you a false/postive alert.
Dos_Probie :mrgreen:

Code: Select all

''Hide your dos console screen - HideConsole.vbs''

CreateObject("Wscript.Shell").Run "MyBatchFile.cmd",0,True

Re: ~ Hide Dos Console ~

Posted: 13 Sep 2012 10:33
by e4nd
"Convert" bat to vbs

Code: Select all

  @echo off & setlocal enabledelayedexpansion
  ::
  :: Skrypt ukrywający okno plików BAT by e4nd
  ::
  set file_=plik.bat
  ::
  ::
  for %%c in (%file_%) do (
        if exist %%c (
        copy %file_% %%~nc.BAK>nul
        set ext=%%~nc
    )else (
        echo Brak pliku %file_% w wskazanej lokalizacji
        pause & exit
    )
)
 :: Zamienia  " na ""
 for /f "tokens=* delims=" %%t in (%file_%) do (
    set S=%%t
    set S=!S:"=""!
    echo !S! >>tmp
   )
)
:VbsCreate
(
  echo Dim oShell
  echo set tmp = CreateObject^("Scripting.FileSystemObject"^)
  echo set File = tmp.CreateTextFile^("tmp.bat", ForWriting^)
) >>%ext%.vbs
  call :ReadFile
(
  echo File.close
  echo Set oShell = WScript.Createobject ^("WScript.Shell"^)
  echo oShell.run "cmd /C tmp.bat" ,0
  echo Set oShell = Nothing
) >>%ext%.vbs
  pause
  endlocal & goto :EOF
::
:ReadFile
::Dodaje do każdej linii  File.WriteLine ("polecenie z pliku bat")
  for /f "tokens=* delims=" %%r in ('type "tmp"') do (
  echo File.WriteLine("%%r"^)>>%ext%.vbs
)
  del /q tmp
  goto :EOF

Re: ~ Hide Dos Console ~

Posted: 13 Sep 2012 10:37
by foxidrive
You may not realise - the comments/echos in the batch are not in English.

Re: ~ Hide Dos Console ~

Posted: 13 Sep 2012 14:10
by Dos_Probie
e4nd,

Thanks for your help but it's all Greek or Polish to me.. :lol: