logging - Cannot log WinZip command line process -


i got following vbscript test code zip test files via winzip command line:

dim strwinzipdir, strzipfiletocreate, strfilestozip, strwinzip, strcommand  strwinzipdir = "c:\program files\winzip\winzip32.exe" strzipfiletocreate = "c:\users\ext_dirmod_01\desktop\testlog.zip" strfilestozip = """c:\users\ext_dirmod_01\desktop\facturasgra.vbs"" ""c:\users\ext_dirmod_01\desktop\test zip windows.vbs"""  set objfso = createobject("scripting.filesystemobject")  strwinzip = objfso.getfile(strwinzipdir).shortpath strcommand = strwinzip & " -min -a -r """ & strzipfiletocreate & """ " & strfilestozip  set objshell = createobject("wscript.shell") set objexec = objshell.exec(strcommand)  while objexec.status = 0 loop 

what want log run of zip process both successful completion , error/s appearance. in case of error want exact message winzip returns.

i have tried several ways:

  • adding greater sign (>) filename @ end of command line suggested in this link. method doesn't write on file.
  • also tried stdout , stderr of shell execution returns empty string.

does know else can/should try?

as @cheranshunmugavel pointed out in comment answer knowledge base article refers winzip command line utility. if want work winzip on command line recommend add-on, though regular winzip executable support some basic command line parameters.

note if want use output redirection (>) must run command in cmd, because redirection provided command interpreter. simplified handling recommend using run method rather exec method unless need programatically read stdout and/or stderr.

set objshell = createobject("wscript.shell") rc = objshell.run("cmd /c " & strcommand & " >c:\path\to\your.log 2>&1", 0, true)  if rc <> 0 wscript.echo "an error occurred (" & rc & ")." wscript.quit rc 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -