diff --git a/codec.m b/codec.m
index df4729ecf3cec4c0f0b937d7e9d07fec7ab79719..78f69d2f3273a5d350e6019ca4b771ab55b43a69 100644
--- a/codec.m
+++ b/codec.m
@@ -99,15 +99,15 @@ HEVCArgList = paramToArgList(HEVCParams);
 extraHEVCArgList = paramToArgList(extraHEVCParams);
 
 if ispc
-    redirect = @(logfile) ['> ',logfile,' | type ' logfile];
+    redirect = @(logfile) ['> "',logfile,'" | type "' logfile, '"'];
 elseif isunix
     redirect = @(logfile) ['| tee ' ,LogFile];
 end
 
 if encode
-    command = [TApp,' ',HEVCArgList,' ',extraHEVCArgList,' ',redirect(LogFileEnc)];
+    command = ['"' TApp,'" ',HEVCArgList,' ',extraHEVCArgList,' ',redirect(LogFileEnc)];
 elseif decode
-    command = [TApp,' ',HEVCArgList,' ',extraHEVCArgList,' ',redirect(LogFileDec)];
+    command = ['"' TApp,'" ',HEVCArgList,' ',extraHEVCArgList,' ',redirect(LogFileDec)];
 end
 
 disp(command)
@@ -115,9 +115,9 @@ status = system(command);
 
 if status
     if encode
-        command = [TApp,' ',HEVCArgList,' ',redirect(LogFileEnc)];
+        command = ['"' TApp,'" ',HEVCArgList,' ',redirect(LogFileEnc)];
     elseif decode
-        command = [TApp,' ',HEVCArgList,' ',redirect(LogFileDec)];
+        command = ['"' TApp,'" ',HEVCArgList,' ',redirect(LogFileDec)];
     end
     
     disp(command)
@@ -140,7 +140,7 @@ function argList = paramToArgList(Params)
 parameters = fieldnames (Params);
 values     = struct2cell(Params);
 
-argList = cellfun(@(param,val) ['--',param,'=',val],parameters,values,'UniformOutput',false);
+argList = cellfun(@(param,val) ['--',param,'="',val,'"'],parameters,values,'UniformOutput',false);
 
 argList = strjoin(argList(:));
 end
\ No newline at end of file