You are not logged in.

#1 12 Dec 2015 12:43

Eehixohw
Member
Registered: 25 Sep 2011
Posts: 40

Is there a way to hide cmd from within cmd?

Is there a way to hide cmd from within cmd script?

For instance, I have the following code (notepad.cmd):

pushd %~dp0
start "" notepad.exe

I would like to hide it by adding a code inside the script. Without adding an external call like hide.vbs notepad.cmd.
Is this possible?
Thank you

Offline

#2 12 Dec 2015 12:54

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Is there a way to hide cmd from within cmd?

Alexander Ceed wrote:

I would like to hide it by adding a code inside the script. Without adding an external call like hide.vbs notepad.cmd.
Is this possible?

Not without an external command.

cmdow can hide a window.

Last edited by foxidrive (12 Dec 2015 12:55)

Offline

#3 12 Dec 2015 12:56

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: Is there a way to hide cmd from within cmd?

AFAIK this is not possible without some sort of external call.  You can potentially embed the VBS within your script, if you want to keep it self contained.  You could either write out the VBS script when needed, and delete it afterwards, or take a look at some hybrid script methods discussed here:
http://www.dostips.com/forum/viewtopic.php?t=5543


cmd | *sh | ruby | chef

Offline

#4 12 Dec 2015 15:42

einstein1969
Member
From: Italy
Registered: 29 Dec 2013
Posts: 25

Re: Is there a way to hide cmd from within cmd?

Are you try to create a link?

It is possible start minimized on link property and the result is that nothing appear ....


Einstein1969

Last edited by einstein1969 (12 Dec 2015 15:43)

Offline

#5 12 Dec 2015 23:27

Eehixohw
Member
Registered: 25 Sep 2011
Posts: 40

Re: Is there a way to hide cmd from within cmd?

bluesxman wrote:

AFAIK this is not possible without some sort of external call.  You can potentially embed the VBS within your script, if you want to keep it self contained.

That's what I'd like to do. Any examples of such a thing?

Offline

#6 13 Dec 2015 09:26

einstein1969
Member
From: Italy
Registered: 29 Dec 2013
Posts: 25

Re: Is there a way to hide cmd from within cmd?

Even this method is not accepted i show how setting a link for running minimized via vbs.

minimize.vbs:

set wshell=createobject("wscript.shell")
set lnk=wshell.createshortcut(wscript.arguments.item(0))
lnk.windowstyle=7
lnk.save

but there is this method for create a HIDDEN (start hidden) link!

@ Echo off 
if not exist "%~f1" ( 
echo not found - "%~f1"
goto :eof
)
> %temp%\.url echo;[InternetShortcut]
>>%temp%\.url echo;URL=%~f1
>>%temp%\.url echo;ShowCommand=0
%temp%\.url
del %temp%\.url

This method is an alternative to use VBS.

I not show the vbs run hidden because is well knowed.

Einstein1969

Offline

#7 14 Dec 2015 09:11

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: Is there a way to hide cmd from within cmd?

Alexander Ceed wrote:

That's what I'd like to do. Any examples of such a thing?

Err yes, in the link that was also in my post.

Actually, can you clarify what you mean by "hide"?  I took you to mean that wanted the active window to be removed from view (including the taskbar button).  This is not achievable without something like a VBS call.  If you just want the window to run in a minimised state, that can be done quite readily when the script starts:

@echo off

if "%~1" NEQ "/child" (
    REM spawn self minimised
    start /min "" cmd /c "%~0" /child %*
    goto :EOF
)

REM main script goes here

Last edited by bluesxman (14 Dec 2015 12:36)


cmd | *sh | ruby | chef

Offline

#8 14 Dec 2015 13:54

Eehixohw
Member
Registered: 25 Sep 2011
Posts: 40

Re: Is there a way to hide cmd from within cmd?

That's exactly what I wanted.
Thank you so much.

Offline

#9 14 Dec 2015 16:47

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: Is there a way to hide cmd from within cmd?

Cool smile


cmd | *sh | ruby | chef

Offline

Board footer

Powered by