I have a command that works fine with command prompt:
CMD /C \"\"C:\\Program Files (x86)\\VideoLAN\\VLC\\VLC\" -vvv \"http://www.foo.com:8085/video.mp4/playl
Lankymart's answer is right:
You just need to escape the quotes in the string correctly, the rule is whenever you want to show a quote in a string double it.
However, you still have unbalanced double quotes in the original code (a surplus trailing "
).
WshShell.Run "CMD /C """"C:\Program Files (x86)\VideoLAN\VLC\VLC"" -vvv ""http://www.foo.com:8085/video.mp4/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9NC8yNy8yMDE3IDEyO=="" :sout=#file{dst=""F:\\Partition C Backup\\Downloads\\Video\\TESTING.mp4"",no-overwrite} :sout-keep"""
This will run as
CMD /C ""C:\Program Files (x86)\VideoLAN\VLC\VLC" -vvv "http://www.foo.com:8085/video.mp4/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9NC8yNy8yMDE3IDEyO==" :sout=#file{dst="F:\\Partition C Backup\\Downloads\\Video\\TESTING.mp4",no-overwrite} :sout-keep"
Sample VBScript (a particular executable cliparserPause.exe
is used to mimic VLC
behaviour):
option explicit
On Error GoTo 0
Dim strResult: strResult = Wscript.ScriptName
Dim sCmdToRun, WshShell, intReturn
' CMD /C ""D:\bat\Prog Files (x86)\cliparserPause.exe" -vvv "http://www.foo.com:8085/video.mp4/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9NC8yNy8yMDE3IDEyO==" :sout=#file{dst="F:\\Partition C Backup\\Downloads\\Video\\TESTING.mp4",no-overwrite} :sout-keep"
sCmdToRun = "CMD /C """"D:\bat\Prog Files (x86)\cliparserPause.exe"" -vvv ""http://www.foo.com:8085/video.mp4/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9NC8yNy8yMDE3IDEyO=="" :sout=#file{dst=""F:\\Partition C Backup\\Downloads\\Video\\TESTING.mp4"",no-overwrite} :sout-keep"""
strResult = strResult & vbNewLine & sCmdToRun
Set WshShell = WScript.CreateObject("WScript.Shell")
intReturn = WshShell.Run( sCmdToRun, 1, true)
strResult = strResult & vbNewLine & Cstr( intReturn )
Wscript.Echo strResult
Wscript.Quit( intReturn )
Output:
==> CMD /C ""D:\bat\Prog Files (x86)\cliparserPause.exe" -vvv "http://www.foo.com:8085/video.mp4/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9NC8yNy8yMDE3IDEyO==" :sout=#file{dst="F:\\Partition C
Backup\\Downloads\\Video\\TESTING.mp4",no-overwrite} :sout-keep"
param 0 = D:\bat\Prog Files (x86)\cliparserPause.exe
param 1 = -vvv
param 2 = http://www.foo.com:8085/video.mp4/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9NC8yNy8yMDE3IDEyO==
param 3 = :sout=#file{dst=F:\\Partition C Backup\\Downloads\\Video\\TESTING.mp4,no-overwrite}
param 4 = :sout-keep
press any key to continue...
==> echo %errorlevel%
-1004
==> cscript //NOLOGO D:\VB_scripts\SO\43649265.vbs
43649265.vbs
CMD /C ""D:\bat\Prog Files (x86)\cliparserPause.exe" -vvv "http://www.foo.com:8085/video.mp4/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9NC8yNy8yMDE3IDEyO==" :sout=#file{dst="F:\\Partition C Bac
kup\\Downloads\\Video\\TESTING.mp4",no-overwrite} :sout-keep"
-1004
==> echo %errorlevel%
-1004
cliparserPause.exe source:
#include "stdafx.h"
#include
#include
#include
int main(int argc, wchar_t* argv[])
{
for (int i = 0; i < argc; ++i)
{
wprintf(L"param %d = %S\n", i, argv[i]);
}
wprintf(L"press any key to continue...");
std::getchar();
exit(-999 - argc); /* exitcode to OS = ( -1000 -supplied_paramaters_count ) */
return 0;
}