Jump to content

ShellExecute causes error: "Windows cannot find..." "Make sure you've typed the name correctly, then try again"

Recommended Posts

Dear Ladies, dear Gentlemen.

I would like to call a self-written program ("Main.exe"), using the command ShellExecute().

$program = "Main.exe"
ShellExecuteWait(@ScriptDir & "\" & $program)

The commands above work fine. But the "Main.exe" expects additional parameters and as soon as I add them

$program = "Main.exe"

Local $path1 = "C"
Local $path2 = "Users\Albert Einstein\Desktop\test"
Local $path3 = "DSC01505"
Local $path4 = ".JPG"
Local $path5 = _PathMake ( $path1, $path2, $path3, $path4 )

ShellExecute(@ScriptDir & "\" & $program & " " & $path5)

I receive an errormessage by windows:  "Windows cannot find...", followed by the string. The message continuous: "Make sure you've typed the name correctly, then try again.".

Google-ing this problem, I think there is something wrong with the spaces between the parameters. So I tried

ShellExecute(@ScriptDir & "\" & $program & ' "' & $path5 & '"')

and instead of "$path5" I typed the string by manually - but all attempts produce the same error message.

When I use the command "run" instead of "ShellExecute", I do not have this problem.


Somebody experienced the same problem (http://www.vbforums.com/showthread.php?733507-RESOLVED-Cannot-make-ShellExecute-work!) and solved it:

Function RunProgram
        mFile = mid(document.activeElement.innerText, 3)
        Set objShell = CreateObject("Shell.Application")
        objShell.ShellExecute """" & mfile & """"
        set objShell = nothing 
    End Function

But I actually do not understand the the """"-part. Could somebody enlighten me, please?
Thanks so much!

Edited by dejhost
path to image in second code section contained an error.
Link to post
Share on other sites

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...