Why I needed the scriptWhen you want to run a script as the currently logged on user as a scheduled task, the CMD will popup as a black window. I searched the Internet and found this several different solutions, but this one can be used to launch any other CMD-scripts.
What it doesIt runs the CMD-script in the background without any popup. Please note that the task scheduler thinks the task is finished when the vbs script has finished, even if the CMD-script still runs in the background. This is something I need to look at some time, if you know how to make it wait for the CMD to finish, please let me know!
How I run itIn CMD you can run it with cscript.exe, but if launched as a scheduled task I prefer to run it with wscript.exe.
' invisible.vbs ' Use this to run batch script invisible ' wscript.exe "<PATH>\invisible.vbs" "
<PATH>\MyBatchFile.cmd" CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False