Recover error WshShell.exec

454 Views Asked by At

I use this command to execute a SQL query

Set cmd = WshShell.Exec("cmd /c set ORACLE_SID="& SERVICE &" && "& ORACLE_HOME & "\BIN\sqlplus.exe -s / as sysdba @C:\teste\nscp_supevision\scripts\teste\requete_vbs\requete_sql_etat_bdd.sql")

it works but I wonder how to handle the case where there is an error in the command

"cmd /c set ORACLE_SID="& SERVICE &" && "& ORACLE_HOME & "\BIN\sqlplus.exe -s / as sysdba @C:\teste\nscp_supevision\scripts\teste\requete_vbs\requete_sql_etat_bdd.sql" 

I tried to get that error with a cmd.exitcode a Err.Number value referred is always 0 even if I put a mistake in my command.

PS: we should not I use a text file

1

There are 1 best solutions below

0
On

Use the ExitCode property of the WshScriptExec object.