hougtimo Posted March 28, 2006 Posted March 28, 2006 Hi,I have an unattended windows installation. In this I have a CMD file that runs from winnt.sif (GuiRunOnce). Now it works perfectly, but it shows the user what it is doing. What i want is it still to show the CMD window, but have no text displayed within it. Is this possibke, and if it is, how would I go about doing it?thanksHougTimo
ZileXa Posted March 28, 2006 Posted March 28, 2006 You can hide batchfiles (.cmd or .bat) completely by using HIDE.EXE or BATCHRUNNER.EXEbatchrunner you can find on msfn, there is a topic.... hide.exe... perhaps google.I use hide.exe for a batchfile, the final thing the batchfile does is start a PDFfile, nice thing is, the batchfile is completely hidden because of hide.exe, but the pdf file is shown. exactly what I wanted.I'm not sure if this is what you mean.
myno Posted March 28, 2006 Posted March 28, 2006 (edited) i prefer to use cmdow.exejust put it into \$OEM$\$$\System32the first string in your .cmd should be "cmdow @ /hid" and you wont c the current command window anymore.i know u want to c the .cmd window but with no text in it, so perhaps you try to play around with cmdow.CMDOW [Version 1.4.2]Win32 Commandline Window Utility for NT4/W2K/XP.© Copyright 2001-2002 Ritchie Lawrence, http://www.commandline.co.uk. CMDOW [window | /T] [/F] [/P] CMDOW /TH | /TV | /MA | /CW | /UW | /AT | /FS | /WM CMDOW window {[/ACT] [/iNA] [/ENA] [/DIS] [/VIS] [/HID] [/MIN] [/MAX] [/RES] [/TOP] [/NOT] [/REN caption] [/MOV left top] [/sIZ width height] [/CLS] [/END]} CMDOW /RUN [state] file [args] window List specified window (if omitted, all windows are listed). /T List windows only shown on the taskbar. /B List windows using bare format (no heading information). /F List windows showing full information (don't truncate any fields). /P List windows showing position and size (left, top, width and height). /TH Tile windows horizontally. /TV Tile windows vertically. /MA Minimize all windows. /CW Cascade windows. /UW Undo tile/minimize/cascade. /AT Intelligent [Alt]-[Tab] /FS Switch to full screen mode. /WM Switch to window mode. /ACT Activate specified window. /INA Inactivate specified window. /ENA Enable specified window. /DIS Disable specified window. /VIS Unhide specified window. /HID Hide specified window. /MIN Minimize specified window. /MAX Maximize specified window. /RES Restore specified window. /REN Rename specified window. /TOP Make window always on top. /NOT Make window not always on top. /MOV Move specified window. /SIZ Resize specified window. /CLS Close specified window. /END Kill process linked to window. /RUN Executes or opens specified file using associated application. state Initial show state of window (/MIN, /MAX or /HID). Default is normal. args Optional commandline arguments passed to launched application. Specify a window by its caption (case insensitive) or handle in hex format. The At symbol '@' may be used to refer to this window. For more help on any parameter use CMDOW /? <parameter>. Eg CMDOW /? /RUN or CMDOW /? window. Edited March 28, 2006 by myno
bledd Posted March 28, 2006 Posted March 28, 2006 cmdow is what you needthere's many different switches for it@ /hid completly hides the window
gunsmokingman Posted March 28, 2006 Posted March 28, 2006 You can use a VBS script to hide the batchExampleAfter the batch has completed it will display a message box that will close it self in 7 seconds.Const Hidden = 0,Normal = 1,Min = 2 Dim Act Set Act = CreateObject("Wscript.Shell") Act.Run("PLACE_YOUR_BATCH_FILE_HERE"),Hidden,True Act.Popup "Completed the script", 7, 0 + 32, "Finished Script"
ZileXa Posted March 28, 2006 Posted March 28, 2006 CMDOW canNOT hide the batchwindow completely, you will see a black window flashing!Personally, I find it an ugly solution. Hide.exe hides it completely, no need to add code or use VBS (some people remove VBS with Nlite). I couldn't find the official website or topic, but here is HIDE.EXEuse hide.exe /? to see the options.dito for BATCHRUNNER.EXEuse batchrunner.exe /? to see the options.But I would recommend HIDE.EXE
gunsmokingman Posted March 28, 2006 Posted March 28, 2006 Here is the advantage of using a VBS, you do not have to relay on 3rd party programs. The script I posted will hide the cmd window completly. No flashesExample scriptSave As Hide_HideWindowComSpec.vbsConst Hide = 0, Norm = 1, Min = 2, Max =3 : Dim Act, CMD1,Fso, Ts, SD, VBSVBS ="\HideWindowComSpec.vbs" : CMD1 = "\TestHideCmd.Cmd" '''' VARIBLES FOR THE SCRIPTSet Act = CreateObject("Wscript.Shell") '''' OBJECT FOR THE SCRIPTSet Fso = CreateObject("Scripting.FileSystemObject") '''' OBJECT FOR THE SCRIPTSet Ts = Fso.CreateTextFile(SD & CMD1) '''' THIS BUILD THE CMD TO RUN THEN THE CMD BUILDS THE TEXT FILESD = Act.ExpandEnvironmentStrings("%Systemdrive%") '''' SET THE SYSTEM DRIVE TO SD'''' WRITE THE CMD THEN RUNS ITTs.WriteLine "@Echo Off" & vbCrLf & "set D=%Date%" & vbCrLf & "Echo The Date : %D% > MyTextTest.txt" &_"&& Echo User Name : %UserName% >> MyTextTest.txt && Echo Windows Dir : %Windir% >> MyTextTest.txt"Ts.Close'''' STARTS THE RUN AND DELETE PHAZEAct.Run(SD & CMD1),Hide,True '''' RUNS THE CMD HIDDENAct.Run("MyTextTest.txt"),Norm,True '''' RUN THE TEXT FILE MADE BY THE CMDFso.DeleteFile(SD & CMD1) '''' DELETES THE FILESFso.DeleteFile("MyTextTest.txt") '''' DELETES THE FILESIf Fso.FileExists(SD & VBS) Then '''' CHECKS THEN DELETE THIS FILEFso.DeleteFile(SD & VBS)End IfHere is a SFX file that will run the above VBS scriptI Gunsmokingman give all users full permission to do what ever they want with this script.HideWindowComSpec.exe
ZileXa Posted March 28, 2006 Posted March 28, 2006 Here is the advantage of using a VBS, you do not have to relay on 3rd party programs. The script I posted will hide the cmd window completly. No flashesgood point
Yzöwl Posted March 28, 2006 Posted March 28, 2006 Most of the time I think we tend to get a little scared of VBScript. If we only need to run a quick command hidden we can meet it half way, remove all the set and dim and const bulk and just invoke a vbs using more familiar batch type coding.Here is an example, it will run the command completely hidden, it will count for 10 seconds and create a directory in the current location called testdirCmdLine="ping -n 11 localhost>nul &&MD testdir"CreateObject("WScript.Shell").run "%comspec% /c " &CmdLine,0,True
gunsmokingman Posted March 28, 2006 Posted March 28, 2006 Most of the time I think we tend to get a little scared of VBScript. If we only need to run a quick command hidden we can meet it half way, remove all the set and dim and const bulk and just invoke a vbs using more familiar batch type coding.Here is an example, it will run the command completely hidden, it will count for 10 seconds and create a directory in the current location called testdirCmdLine="ping -n 11 localhost>nul &&MD testdir"CreateObject("WScript.Shell").run "%comspec% /c " &CmdLine,0,TrueI only put in that in as a force of habit. This is the same script as Yzöwl, but I have added a open the folder then it waits for you to close the folder then it deletes the folder.CreateObject("WScript.Shell").run "%comspec% /c " &CmdLine,0,TrueCreateObject("WScript.Shell").run("explorer.exe " & CreateObject("WScript.Shell").CurrentDirectory & "\testdir"),1,True CreateObject("Scripting.FileSystemObject").DeleteFolder(CreateObject("WScript.Shell").CurrentDirectory & "\testdir")
spazmire11 Posted March 28, 2006 Posted March 28, 2006 What i want is it still to show the CMD window, but have no text displayed within it.wow he dosent need all of that stuff this can be achived with a simpleecho offthen when you want to display text just use echo "text"if you want it to show the commands again then just do echo on.
Djé Posted March 28, 2006 Posted March 28, 2006 (edited) Most of the time I think we tend to get a little scared of VBScript.That's very true!Specially when displayed as a dense blue text like in the code/quote boxes of this forum.That's a pitty there is no color coding for the main languages used here. Something like [code type=vbs] tags.Anyway, I loved (and understood!) your simple 2 lines example. I may try VBS one day... ...When I will have forgotten a bit how frustrating its sibling VBA is. Anyway, spazmire11 has the right answer to the original question, I guess.wow he dosent need all of that stuff this can be achived with a simple echo off Edited March 28, 2006 by Djé
Yzöwl Posted March 28, 2006 Posted March 28, 2006 Technically no, what is actually required for the original question is to run the batch file with stderr and stdout redirectedmybatch.cmd >nul 2>&1There may be a problem with this syntax however from GuiRunOnce in winnt.sif.
jdoe Posted March 29, 2006 Posted March 29, 2006 (edited) I know it's not relevent anymore since everyone misunderstood the real question and the good answer must be the one from Yzöwl about >nul (with echo off).But about hiding command prompt window without using 3rd party program or VBScript there is one more solution I don't remember having see in other topics.TEST.INF[Version]Signature="$Windows NT$"AdvancedINF=2.5[DefaultInstall]RunPostSetupCommands=DefaultInstall.RunPostSetupCommands:1[DefaultInstall.RunPostSetupCommands]TEST.CMDAnd you call it like thisrundll32.exe advpack.dll,LaunchINFSection TEST.INF,DefaultInstall Edited April 5, 2006 by jdoe
Djé Posted March 29, 2006 Posted March 29, 2006 Technically no, what is actually required for the original question is to run the batch file with stderr and stdout redirectedmybatch.cmd >nul 2>&1There may be a problem with this syntax however from GuiRunOnce in winnt.sif.Yes, after posting, I just remembered one of your posts showing the >nul for stdout, although it was for each individual command.What is that 2>&1 doing for stderr ??And maybe hougtimo doesn't want that level of nudity (that is really bare bone) and would appreciate a few veils of echo to tell what's going on? but that's just a conjecture.rundll32.exe advpack.dll,LaunchINFSection TEST.INFHey, jdoe, you seems to know a lot about that advanced inf syntax. Do you have some link to good documentation about it?Last time I could not manage to register/unregister dlls using that advpack.dll,LaunchINFSection stuff.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now