## Recommended Posts

Shouldn't this just work?

Run("wmplayer.exe 'I:\Treasures\Treasures Listening Library\Supplemental Readers\Grade 1.m3u'")

I've been coding things all day and the simplest of scripts is eluding me. Why? I'm not sure.

I also tried:

ShellExecute("I:\Treasures\Treasures Listening Library\Supplemental Readers\Grade 1.m3u")

That also does not work.   Yes, the file exists. Yes, permissions are correct. Yes I can navigate to the file and double-click to run and it opens media player.

##### Share on other sites

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)

There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

##### Share on other sites

Thanks for the link, but damned if it won't work.  I even shortened it to :

ShellExecute("C:Program FilesWindows Media Playerwmplayer.exe")

It just refuses to open.

Thanks again. I'll dive back into this Monday. It's time for the weekend.

##### Share on other sites

A CMD prompt is quite verbal so it can help to troubleshoot a path issue.

C:\>wmplayer.exe
'wmplayer.exe' is not recognized as an internal or external command,
operable program or batch file.

Lets try C:Program FilesWindows Media Playerwmplayer.exe

C:\>C:\Program Files\Windows Media Player\wmplayer.exe
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

1st attempt is that Windows does not know where wmplayer.exe is. It is not in the current directory or in the PATH variable.

2nd attempt is 3 parameters as whitespace is known as a parameter terminator and is thus a delimiter for parameters. You may see

C:\Program Files\Windows Media Player\wmplayer.exe

Windows may see up to 4 separate parameters

C:\Program
Files\Windows
Media
Player\wmplayer.exe

Using quotes can be vital to success. The use of possible quotes in the 1st parameter of Run() and the 1st 2 parameters of ShellExecute() can be of concern with possibly needing quotes.

Give this example a try which may help to show the quote issue with the 1st parameter of Run

#include <WinAPI.au3>

_Run('wmplayer.exe')
_Run("C:\Program Files\Windows Media Player\wmplayer.exe")
_Run('"C:\Program Files\Windows Media Player\wmplayer.exe"')

Func _Run($parameter) Local$expect_failure, $last_error_msg,$pid
; Check if unquoted string which has whitespace
$expect_failure = 'No' ; check if string is not quoted If Not StringRegExp($parameter, '[''"]') Then
; check if string has whitespace
If StringReplace($parameter, ' ', '') And @extended Then$expect_failure = 'Perhaps as ' & $parameter & ' is whitespace delimited ' & _ 'so it could be considered as ' & @extended + 1 & ' parameters' ElseIf Not FileExists($parameter) Then
$expect_failure = 'Perhaps as ' &$parameter & ' does not exist in current path'
EndIf
EndIf
; run the command
$pid = Run($parameter)
; get last error message
$last_error_msg = _WinAPI_GetLastErrorMessage() ; wait for process to be closed ProcessWaitClose($pid)
; show the result
MsgBox(0x40000, 'Result', _
'$parameter:' & @CRLF & _$parameter & @CRLF & @CRLF & _
'$expect_failure:' & @CRLF & _$expect_failure & @CRLF & @CRLF & _
'$last_error_msg:' & @CRLF & _$last_error_msg _
)
EndFunc

Expect the last Run function to succeed as it has double quotes around the path which has whitespace in it.

##### Share on other sites

Ok that tidbit of code works just fine. But if I try to duplicate that, it just sits there, never running wmplayer.  Someone asked previously about other factors.

Did you try Run? Does the path exist? What version of AutoIt are you using? Your system? e.g. 64-bit?

Run?  Yes I tried, won't open wmplayer.  Path Exist? Yep. Works perfectly fine any other time.   AutoIt version)  SciTE Version 3.3.0 & AutoIt  v3.3.8.1

System) Win7 Pro 32-bit

if I open a command window, and navigate to the root c:, and use  "c:program fileswindows media playerwmplayer.exe", it runs.  If I navigate to the directory where the .m3u resides,I:TreasuresTreasures Listening LibrarySupplemental Readers>, and type "Grade 1.m3u" and hit enter, wmplayer pops up and begins to play the file.

That's why I tried a

ShellExecute("I:\Treasures\Treasures Listening Library\Supplemental Readers\Grade 1.m3u")

and it still won't open.  The console window that shows the script functioning says  "Exit Code: 1   Time 0.409"

so it's doing something, just NOT opening the damn wmplayer

##### Share on other sites

Now I had the thought of trying to force a path to wmplayer using _PathMake().  I can assign all the parameters, and msgbox() it, but it still refuses to run. ARRRGGGHHHH!!!!!

ETA:

WTF?!?!? It just started working for no good reason. Using only

ShellExecute("I:\Treasures\Treasures Listening Library\Supplemental Readers\Grade 1.m3u")

What the hell changed?  to be sure I even rebooted the machine and it still works.

Edited by PDowning

##### Share on other sites

Now I had the thought of trying to force a path to wmplayer using _PathMake().  I can assign all the parameters, and msgbox() it, but it still refuses to run. ARRRGGGHHHH!!!!!

Copy and rename a working MP3 file to X:Test.mp3. Here, X: is the drive letter (J:, K etc.) of an USB stick formatted in either FAT32 or exFAT. From a DOS prompt, type the following:

X:

start Test.mp3

If the assigned music player doesn't starts, then it won't from AutoIt either. Fix this via your music player (file extension associations). Assuming this works, we can try the same via an AutoIt script:

ShellExecute("X:Test.mp3")

I bet this will work for you. If not, then your antivirus software is keeping AutoIt in a sandbox or something. In such cases, it could even be that a compiled script works whereas an .AU3 doesn't, or the other way around. In any case, add AutoIt3.exe and/or your compiled .exe file to the trused file list.

If everything works like expected, move the file to "C:Test.mp3" and then try:

ShellExecute("C:Test.mp3")

If if works, then it seems that there's no problem and you probably made a typo in your script. If this doesn't work, you now know that the problem is somehow NTFS-related.

##### Share on other sites

read the ETA in my last post.

##### Share on other sites

ETA:

WTF?!?!? It just started working for no good reason. Using only

ShellExecute("I:\Treasures\Treasures Listening Library\Supplemental Readers\Grade 1.m3u")

What the hell changed?  to be sure I even rebooted the machine and it still works.

Computers are ... in essence ... female.  They do what they bloody well please.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

##### Share on other sites

I am late on my reply on this but I was hoping that my last post explained the issue. It is about how to use quotes. If you can not get it to work on the command line then you may have little hope with Run() or ShellExecute(). And the comment about If computers are female, then perhaps they just need caressing. I like computers and females so the comment may be true .

Whitespace terminates a parameter. So

ShellExecute("I:\Treasures\Treasures Listening Library\Supplemental Readers\Grade 1.m3u")

can fail as the execution may see

I:\Treasures\Treasures
Listening
Library\Supplemental
1.m3u

as 5 parameters. To make it show as 1 parameter then you may need to include quotes to tell the system to handle it as one parameter.

Example:

ShellExecute('"I:\Treasures\Treasures Listening Library\Supplemental Readers\Grade 1.m3u"')

may see

"I:\Treasures\Treasures Listening Library\Supplemental Readers\Grade 1.m3u"

The single quotes wrap the double quotes so the double quotes remain as part of the string. Thus it is treated as one parameter.

Example of a command line using Run()

Run('"path\to\program.exe" "parameter 1" "parameter 2" "parameter 3"')

would see

"path\to\program.exe"
"parameter 1"
"parameter 2"
"parameter 3"

The use of quotes ensures that whitespace within the quotes are treated as part of the parameter and whitespace outside of the quotes is treated as the terminator of the parameters. If you have no whitespace in any of the parameters the quotes are optional with those parameters.

##### Share on other sites

Computers are ... in essence ... female.  They do what they bloody well please.

That is one thing that I do believe completely about PC's  ...

##### Share on other sites

I am late on my reply on this but I was hoping that my last post explained the issue. It is about how to use quotes. If you can not get it to work on the command line then you may have little hope with Run() or ShellExecute(). And the comment about If computers are female, then perhaps they just need caressing. I like computers and females so the comment may be true .

Whitespace terminates a parameter. So

ShellExecute("I:\Treasures\Treasures Listening Library\Supplemental Readers\Grade 1.m3u")

can fail as the execution may see

I:\Treasures\Treasures
Listening
Library\Supplemental
1.m3u

as 5 parameters. To make it show as 1 parameter then you may need to include quotes to tell the system to handle it as one parameter.

Example:

ShellExecute('"I:\Treasures\Treasures Listening Library\Supplemental Readers\Grade 1.m3u"')

may see

"I:\Treasures\Treasures Listening Library\Supplemental Readers\Grade 1.m3u"

The single quotes wrap the double quotes so the double quotes remain as part of the string. Thus it is treated as one parameter.

Example of a command line using Run()

Run('"path\to\program.exe" "parameter 1" "parameter 2" "parameter 3"')

would see

"path\to\program.exe"
"parameter 1"
"parameter 2"
"parameter 3"

The use of quotes ensures that whitespace within the quotes are treated as part of the parameter and whitespace outside of the quotes is treated as the terminator of the parameters. If you have no whitespace in any of the parameters the quotes are optional with those parameters.

I am late on my reply on this but I was hoping that my last post explained the issue. It is about how to use quotes. If you can not get it to work on the command line then you may have little hope with Run() or ShellExecute(). And the comment about If computers are female, then perhaps they just need caressing. I like computers and females so the comment may be true .

Whitespace terminates a parameter. So

ShellExecute("I:\Treasures\Treasures Listening Library\Supplemental Readers\Grade 1.m3u")

can fail as the execution may see

I:\Treasures\Treasures
Listening
Library\Supplemental
1.m3u

as 5 parameters. To make it show as 1 parameter then you may need to include quotes to tell the system to handle it as one parameter.

Example:

ShellExecute('"I:\Treasures\Treasures Listening Library\Supplemental Readers\Grade 1.m3u"')

may see

"I:\Treasures\Treasures Listening Library\Supplemental Readers\Grade 1.m3u"

The single quotes wrap the double quotes so the double quotes remain as part of the string. Thus it is treated as one parameter.

Example of a command line using Run()

Run('"path\to\program.exe" "parameter 1" "parameter 2" "parameter 3"')

would see

"path\to\program.exe"
"parameter 1"
"parameter 2"
"parameter 3"

The use of quotes ensures that whitespace within the quotes are treated as part of the parameter and whitespace outside of the quotes is treated as the terminator of the parameters. If you have no whitespace in any of the parameters the quotes are optional with those parameters.

The thing is, there are only double quotes on that line. No single quotes at all. Oh well, it's working.

##### Share on other sites

Run("wmplayer.exe 'I:\Treasures\Treasures Listening Library\Supplemental Readers\Grade 1.m3u'")

I don't think Windows recognizes ' as an alias to " the same way as autoit does it. Do like this:

Run('wmplayer.exe "I:\Treasures\Treasures Listening Library\Supplemental Readers\Grade 1.m3u"')

Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG

##### Share on other sites

For some unknown reason, this

ShellExecute("I:\Treasures\Treasures Listening Library\Supplemental Readers\Grade 1.m3u")

started working. Oh well, not gonna mess with it anymore. It works, leave it alone. Always been my motto

## Create an account

Register a new account