0

This is my .bat. All is working fine, except i see the black window on my screen while the countdown is taking place...

@echo off
timeout /nobreak /t 8 > nul
start /d "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Skype\" Skype.lnk
exit

Ps: /min doesn't work, skype doesn't start minimized even if i right click on the skype.lnk in the program files and set there start as minimized.

Thank you in advance!

Endoro
  • 37,015
  • 8
  • 50
  • 63
Eddy
  • 1
  • 1
  • Welcome to S.O. Eddy. Since you're just starting out here, you ought to see [this information](http://meta.stackexchange.com/a/5235/187716) regarding marking answers as accepted. – rojo Apr 17 '13 at 13:36

1 Answers1

0

I haven't tested this, but I think it should work. It's a batch + JScript + batch again hybrid script. Save this with a .bat extension and let me know whether it works for you. If not, I'll do some testing.

@if (@a==@b) @end /*

:: batch portion

@echo off
tasklist /fi "IMAGENAME eq cscript.exe" | find /i "cscript.exe" >NUL || (
    start "" cscript /nologo /e:jscript "%~f0"
    exit
)
:: ping -n seconds + 1 (because first ping result is instant)
ping -n 9 localhost > nul
start /d "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Skype\" Skype.lnk
exit

:: JScript portion */
var sh = new ActiveXObject("WScript.Shell");
sh.Run(WSH.ScriptFullName, 0);
WSH.Sleep(100);

I'll attempt to describe the workflow of the script.

  1. cmd batch: User launches batch script either by double-clicking or entering batfile.bat at the cmd prompt.

  2. Script checks to see whether cscript.exe is in the task list. It isn't.

  3. Script re-launches itself using the JScript interpreter instead of the cmd batch interpreter. Current cmd interpretation exits.

  4. JScript: The WScript.Shell object Run method re-launches the batch script with the cmd interpreter in a hidden, non-blocking process.

  5. After a 100ms pause, JScript reaches the end of the file and exits. This should be the last of the visible windows.

  6. invisible cmd batch: Script checks to see whether cscript.exe is in the task list. JScript is still pausing at this point, so cscript.exe does exist.

  7. Go ping yourself... for 8 seconds.

  8. Activate the Skype shortcut in a non-blocking process.

  9. Batch script exit.

rojo
  • 24,000
  • 5
  • 55
  • 101