0

I have an executable which scans my drives when I directly run it. However same executable is fails to run when used below VB Script to run the executables

Sub ScanDrive
   Dim objShell, objExec
   Set objShell = CreateObject("WScript.Shell")
   wscript.sleep 5000
   strErrorCode = objShell.Run(".\scanmydrive.exe /ADL /SECURE /NOBREAK" ,0 , True)
   WScript.StdOut.write(".")
   WScript.Sleep 1000   
   Wscript.echo strErrorCode 
End Sub

There is no error thrown? Is it sleeping? :)

Updated Question

When I directly run the executable, it shows a message as follows, which proves that executable is not started if it triggered from script.

 Engine version: 1100.19 for Win32.
 Scanning started.

 c:\$Recycle.Bin\S142223018-65415\$I906XC1.log
kudlatiger
  • 3,028
  • 8
  • 48
  • 98
  • How do you know it doesn't run if no error is thrown? If you want to get the output from the ran executable you should be using `.Exec()` which gives you access to `StdOut`. See [vbscript .run show output](https://stackoverflow.com/a/34500754). – user692942 Aug 10 '22 at 10:26
  • It shows welcome message when i directly run the exe. Updated the question. – kudlatiger Aug 10 '22 at 10:29
  • Yeah, as I thought. Just because you don't see any output doesn't mean the executable didn't run. You're assuming it didn't run which is why you should use `Exec()` instead of `Run()` as that gives you access to the executable output (see suggested duplicate). – user692942 Aug 10 '22 at 10:32
  • when i change, it shows Microsoft VBScript runtime error: Wrong number of arguments or invalid property assignment: 'objShell.Exec' – kudlatiger Aug 10 '22 at 10:34
  • 1
    Suggest looking at the [`Exec()` method](https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/scripting-articles/ateytk4a(v=vs.84)) documentation and looking at how it is used in the suggested duplicate. – user692942 Aug 10 '22 at 10:38
  • Okay, let me try and update the answer in StackOverflow so that it helps the community – kudlatiger Aug 10 '22 at 10:38
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/247176/discussion-between-kudlatiger-and-user692942). – kudlatiger Aug 10 '22 at 10:41

0 Answers0