Se a conexão falhar, então MsgBox “Não há conexão disponível”. Em qual comando a 'conexão falha' deve ser substituída?

1

Qual comando deve 'conexão falhar' na cláusula if ser substituído por?

createobject("wscript.shell").run "Rasdial connection_name account_name password",0

If connection fails, then 
MsgBox "There is no available connection."
End If
    
por Matthew Wai 15.12.2016 / 12:04

1 resposta

1

Leia Executar o método (host de scripts do Windows) ;

Runs a program in a new process.

Syntax

object.Run(strCommand, [intWindowStyle], [bWaitOnReturn]) 

Arguments

  • object - WshShell object.
  • strCommand - String value indicating the command line you want to run. You must include any parameters you want to pass to the executable file.
  • intWindowStyle - Optional. Integer value indicating the appearance of the program's window. Note that not all programs make use of this information.
  • bWaitOnReturn - Optional. Boolean value indicating whether the script should wait for the program to finish executing before continuing to the next statement in your script. If set to true, script execution halts until the program finishes, and Run returns any error code returned by the program. If set to false (the default), the Run method returns immediately after starting the program, automatically returning 0 (not to be interpreted as an error code).

O próximo snippet de código pode funcionar para você:

retValue = createobject("wscript.shell").run ( _
      "Rasdial connection_name account_name password",0 , True)

If retValue <> 0 then
    MsgBox "There is no available connection."
End If
    
por 04.01.2017 / 23:14