nircmd mediaplay: access is denied

I'm trying to make a bat file that when launched will open a mediafile and close after x-number milliseconds.

mediaplay [play time] [audio file]

I'm trying to use nircmd's media play command, but it dosen't recognize it. I've tried the following codes in cmd.

C:\Users\Lind>mediaplay 10000 "C:\Users\Lind\Music\1.mp3"
'mediaplay' is not recognized as an internal or external command,
 operable program or batch file.

I've also tried this but nothing happend

C:\Users\Lind>nircmd.exe mediaplay 10000 "C:\Users\Lind>Music>1.mp3"

**************************************Update************************************

I found out that I've made a mistake in the mp3 file directory name, now it just says

C:\Users\Lind>nircmd.exe mediaplay 10000 "C:\Users\Lind>Music\1.mp3"

Access is denied.

I've tried using cmd as an adminstrator, but then nothing happens.

Upvotes: 0

Views: 714

Answers (3)

VIRNARRA
VIRNARRA

Reputation: 11

Double check if you didn't turn the nircmd.exe file into a empty file using that command you just did. It should not be a 0kb file. I made the same mistake and turned my exe into a empty file.

Reinstall Nircmd and you should be good with the new command.

Upvotes: 0

Compo
Compo

Reputation: 38709

If you do not provide the location of nircmd.exe you will need to make sure that nircmd.exe resides within the current directory or a location defined under %PATH%:

Here's an example for you:

@Echo Off
Rem MediaPlay command
Set "mp="C:\Users\Lind\Utilities\NirSoft\nircmd.exe" MediaPlay"

Rem MusicFile location
Set "mf=C:\Users\Lind\Music\1.mp3"

Rem MilliSeconds
Set "ms=10000"

Rem Start it
Start "" %mp% %ms% "%mf%"

Just change the values after the = for the three Set statements as required, (but do not remove or change any of the "'s).

Note: nircmd.exe and nircmdc.exe are both flagged as potential security threats by most antivirus/antimalware programs. If you have one of those then, you'd have to see if you can make an exception for it to run from within your security software.

Upvotes: 1

Magoo
Magoo

Reputation: 80138

In order to execute any external command (ie. any command that is not internal to cmd.exe itself), then you need to do one of the following:

  1. Specify the precise location of the executable (eg use "c:\wherever\your\mediaplay\is located\mediaplay" in place of mediaplay (quotes required if the path or executable name contains separators like spaces))

  2. Include the directoryname for mediaplay into the path variable. This can be done on a permanent basis by using Control Panel>System>Advanced System Settings>Advanced>Environment Variables or preferably by using a dedicated editor like Path Editor or on a temporary basis by prefixing that path; to the path variable within a batch or manually from the prompt.

  3. Navigate to the mediaplayer directory using the three lines "pushd mediaplayerdirectoryname", "mediaplayer...", "popd" (all without the quotes)

The last method is a special case of the second which uses the windows' executable-search strategy to look for an executable first in the current directory, and then in each directory specified in the path variable in turn until the executable is found.

Upvotes: 0

Related Questions