run and wait issue

Started by Martin Goldberg, November 15, 2021, 10:15:03 AM

Previous topic - Next topic

Martin Goldberg

In the code below run and wait works for Microsoft written programs, but not for a compiled Winbatch .EXE.   one, three, and four work.  Two fails.  Any ideas why?

programpath = "c:\program files\synovative technology\OR_Case_Load_estimator"
datapath = StrCat(logpath, "body.txt")
path1 = "c:\windows\notepad.exe"
path2 = "c:\program files\synovative technology\OR_Case_Load_estimator\emailreturn.exe"
path3 = "C:\Program Files (x86)\Microsoft Office\root\Office16\winword.exe"


Pause(DirGet(), StrCat("Run It 1", @crlf, path1))
RunShell(path1, datapath, programpath, @normal, @wait)   ;works
TimeDelay(3)

Pause(DirGet(), StrCat("Run It 2", @crlf, path2))
RunShell(path2, "", programpath, @normal, @wait)         ;fails
TimeDelay(3)

Pause(DirGet(), StrCat("Run It 3", @crlf, path1))
RunShell(path1, datapath, programpath, @normal, @wait)   ;works
TimeDelay(3)

Pause(DirGet(), StrCat("Run It 4", @crlf, path3))
RunShell(path3, datapath, programpath, @normal, @wait)   ;works


td

The reason depends on which "Comple type" option is used on the compiled script and the permissions the user executing the "RunWait" function has. RunWait should produce an error message that may help explain the problem.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Neglected to mention the compiler UAC settings vs system UAC settings and user permission level possible cause.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

Martin Goldberg

The compiled code is the small module and it runs when clicked on in its folder as the larger DLL is also there.
I have used factory settings for all other things mentioned in previous responses to this issue.  Some I am not really familiar with.
Note the code is not RUNWAIT, but rather RUNSHELL.
In addition, the same results also occur when run as a text script (WBT)

td

RunWait or RunShell that distinction doesn't matter that much in this case because you are using the full path to the compiled script and I have no idea what you mean by "factory settings". Again when you say "fails". What exactly happens? There should be an error message that should help identify the nature of your problem. If you don't see an error message you have a coding error in your script or you are suppressing errors. If you are suppressing errors you need to stop. Debugging a problem with error messaging turned off is just wasting your and other people's time.

You can also try the "ShellExecute" function instead of "RunShell". If ShellExecute works then your problem is likely UAC related.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

In order to eliminate the dreaded "antimalware" problem, you could create a simple one-line script in the hard drive location of your problematic compiled script. A Message("Hello", "word") line would be sufficient.  If you can run that script from file explorer, compile it. If the resulting exe is launchable from the same drive location, you likely do not have an antimalware problem.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

kdmoyers

Quote from: td on November 16, 2021, 05:26:56 PMMessage("Hello", "word") line would be sufficient
This is how we confirmed our antimalware problem.  Now that we know about it, we just whitelist our compiled stuff.  Problem gone.
The mind is everything; What you think, you become.

Martin Goldberg

My thanks to all for the help.  Happy Holidays!  Marty