Sign in to follow this  
Followers 0
JohnBailey

Vars and Run

16 posts in this topic

#1 ·  Posted (edited)

Why won't this work? It won't run the file - giving me "Unable to execute the external program." If I specify in the file what the location and name is in Run(here), then it works. However, it gives that error when I do it using the below method.

$nextItemProgram = _GUICtrlListViewGetItemText($ListView1, $nextItem, 5)
GUICtrlSetData($Status, "Program " & $nextItemName & " Ran   "& $nextItemProgram)
Dim $szDrive, $szDir, $szFName, $szExt  ;<--- straight from the help file
$TestPath = _PathSplit($nextItemProgram, $szDrive, $szDir, $szFName, $szExt) ;<--- straight from the help file
Run($nextItemProgram,$szDrive&$TestPath[2])

Edit: corrected syntax

Edited by JohnBailey

A decision is a powerful thing

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this:

$nextItemProgram = _GUICtrlListViewGetItemText($ListView1, $nextItem, 5)
GUICtrlSetData($Status, "Program " & $nextItemName & " Ran   "& $nextItemProgram)
Dim $szDrive, $szDir, $szFName, $szExt  ;<--- straight from the help file
$TestPath = _PathSplit($nextItemProgram, $szDrive, $szDir, $szFName, $szExt) ;<--- straight from the help file
MsgBox(0,'', $nextItemProgram & @LF & $szDrive & @LF & $TestPath[2])

Maybe what's being passed to Run() is not what you're expecting.

*Edit: Also uh, you know that the 3rd parameter for run (where you're passing $szDrive&$TestPath[2]) is the window flag. It takes a value like @SW_HIDE, @SW_MAXIMIZE, or @SW_MINIMIZE.

*Edit of edit: You edited your post and corrected the very thing I pointed out in this edit. So ignore this.

Edited by Saunders

Share this post


Link to post
Share on other sites

Saunders, yeah I thought that too. However, the msgbox reveals the correct information.


A decision is a powerful thing

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

By th ecorrect information do you mean correct to use in your script as you have shown?

I would expect that you would need to add ':\' to the drive, '\', to the path and '.' before the extension. (But I haven't looked to see what Drive Split returns.)

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Just so you know, since I can't see what's in the $nextItemProgram variable, it has to be a full path. For example, this will fail:

Run('Program.exe', '"C:\Program Files\Folder"')

Even if Program.exe is in that folder.

Share this post


Link to post
Share on other sites

The name file I:\SAI\Auto-It files\Internet Log Transfers - 10am - (M).exe

this works

Run('"I:\SAI\Auto-It files\Internet Log Transfers - 10am - (M).exe"','I:\SAI\Auto-It files\')oÝ÷ ÚØb±Ú²z-jëh×6Run($nextItemProgram,'I:\SAI\Auto-It files\')

A decision is a powerful thing

Share this post


Link to post
Share on other sites

Are there quotation marks around the filename in the variable? If you're pulling from a ListView, chances are there aren't.

That seems to be a common pitfall.

Share this post


Link to post
Share on other sites

This is the problem - $nextItemProgram = '"I:\SAI\Auto-It files\Internet Log Transfers - 10am - (M).exe"'

It is a valid file name and path

This works - $nextItemProgram = '"I:\SAI\Auto-It files\MA Run.exe"'

Does it have something to do with the (M)


A decision is a powerful thing

Share this post


Link to post
Share on other sites

I can't imagine... unless of course that file doesn't exist. But you've already checked that right? Please tell me you already checked that... :whistle:

Share this post


Link to post
Share on other sites

yes :whistle: I've verified several times that it is a valid file name and location


A decision is a powerful thing

Share this post


Link to post
Share on other sites

yes :whistle: I've verified several times that it is a valid file name and location

at times i have needed to do it this way

If FileExists($program) Then RUNWAIT( FileGetShortName($program) )

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Ok, I'm an idiot! I didn't think that there could be a problem with the exe haha. I thought I was just scripting wrong!

:duh:

:whistle: thanks guys!

I corrected the problem inside Internet Log Transfers - 10am - (M).exe and it works fine now. Miss one thing during diagnosis and you'll be scratching your head forever :P


A decision is a powerful thing

Share this post


Link to post
Share on other sites

Good call Valuater! I use that method a lot and it works wonders. I've never used the shortname part. Why that little added bit? Is that incase you're on an older OS or one that limits chars?


A decision is a powerful thing

Share this post


Link to post
Share on other sites

I guess I needed

_DoesTheExeWorkYouDork()

:whistle:


A decision is a powerful thing

Share this post


Link to post
Share on other sites

Good call Valuater! I use that method a lot and it works wonders. I've never used the shortname part. Why that little added bit? Is that incase you're on an older OS or one that limits chars?

No sometimes it helps with spaces in the file name/location for me

I guess I needed

_DoesTheExeWorkYouDork()

:P

LOL... :whistle:

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

No sometimes it helps with spaces in the file name/location for me

Oh, cool. I'll keep that in mind! I've had that problem before!


A decision is a powerful thing

Share this post


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
Sign in to follow this  
Followers 0