Jump to content

Recommended Posts

Posted

Hello everyone, could someone help me understand why this code isnt executing the program?

$CWD = "\\domain\SoftwareData\CWD-Daten\ClinicWD\exe\ClinicWD.exe"

if FileExists($CWD) Then
    $PID=ShellExecute($CWD)
    MsgBox(0,"CWD File found","The Program " & $CWD & " has been started with PID=" & $PID)
Else    
    MsgBox(48,"CWD not found","The Program " & $CWD & " doesn't seem to exist.")
EndIf

 

I have also tried this with "Run" instead of "ShellExecute" but it isnt working.

When i run this script, it always displays the message it's supposed to give when it works ("CWD File found, The Program CWD has been started with PID=xxxx"), but it never actually opens the program.

 

Any and all input appreciated.

Posted

Maybe this program requires some other files (dll, ico, etc) that do not exist on your computer.  Try to create a map drive, change directory to it and launch the program.  See if that work.  Try manually first on a cmd window.

Posted

Thanks for the recommendation!

I have now mapped the folder which contains the .exe and changed the path in the script. Unfortunately, this also doesnt work.

I have a shortcut for the same .exe file im referencing in the script, and when i double click that, the program opens as expected.
So it shouldnt be missing any files, right?

  • Developers
Posted

Couple of things to try:

  1. Set the workdir parameter to the same directory as the program.
  2. try running it from the CMD prompt to see whether it works at all.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted
  On 12/12/2019 at 1:14 PM, Funkk said:

So it shouldnt be missing any files, right?

Expand  

Not necessary, can you check if the working folder is set in your shortcut.  If it is, then that might be your issue with ShellExecute...As I and Jos told you, try running the program from a cmd window (DOS prompt) first.

Posted
  On 12/12/2019 at 1:31 PM, Nine said:

As I and Jos told you, try running the program from a cmd window (DOS prompt) first.

Expand  

I have tried to run the program from a CMD window and it didnt work.

 

  On 12/12/2019 at 1:31 PM, Nine said:

Not necessary, can you check if the working folder is set in your shortcut.

Expand  

Im not sure if i got the right thing, but if you mean "Start in" in the shortcuts properties, it is set. It's set to exactly the same path im referencing in the script.

 

  On 12/12/2019 at 1:23 PM, Jos said:

Couple of things to try:

  1. Set the workdir parameter to the same directory as the program.
Expand  

Im also not too sure about this, but i added a line and my script looks like this now:

$CWD = "\\ksbl.local\softwaredata\CWD-Daten\ClinicWD\exe\ClinicWD.exe"
FileChangeDir("\\ksbl.local\softwaredata\CWD-Daten\ClinicWD\exe\ClinicWD.exe")

if FileExists($CWD) Then
    $PID=ShellExecute($CWD)
    MsgBox(0,"CWD File found","The Program " & $CWD & " has been started with PID=" & $PID)
Else
    MsgBox(48,"CWD not found","The Program " & $CWD & " doesn't seem to exist.")
EndIf

This hasnt solved my problem, so i doubt it's correct.

Posted

Not quite :) There's a working directory parameter in ShellExecute that they'd like you to use.

Local $CWD = "\\ksbl.local\softwaredata\CWD-Daten\ClinicWD\exe\ClinicWD.exe"
Local $sWorkingDirectory = "\\ksbl.local\softwaredata\CWD-Daten\ClinicWD\exe\"


if FileExists($CWD) Then
    $PID=ShellExecute($CWD, "", $sWorkingDirectory))
    MsgBox(0,"CWD File found","The Program " & $CWD & " has been started with PID=" & $PID)
Else
    MsgBox(48,"CWD not found","The Program " & $CWD & " doesn't seem to exist.")
EndIf

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

  Reveal hidden contents
Posted

Not so much thanks to me, but Jos and Nine... they suggested it, I just showed you what they meant. Glad your problem was fixed though :)

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

  Reveal hidden contents
Posted

Check your AV software setting, and check security zones in Windows.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...