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.
cmd batch: User launches batch script either by double-clicking or entering batfile.bat
at the cmd
prompt.
Script checks to see whether cscript.exe
is in the task list. It isn't.
Script re-launches itself using the JScript interpreter instead of the cmd batch interpreter. Current cmd interpretation exits.
JScript: The WScript.Shell object Run method re-launches the batch script with the cmd interpreter in a hidden, non-blocking process.
After a 100ms pause, JScript reaches the end of the file and exits. This should be the last of the visible windows.
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.
Go ping yourself... for 8 seconds.
Activate the Skype shortcut in a non-blocking process.
Batch script exit.