Setvol not working from within batch filr

Here you are welcome to discuss items of general interest related to SetVol
Post Reply
Kichiji
Posts: 3
Joined: Sun Aug 11, 2019 5:31 pm

Setvol not working from within batch filr

Post by Kichiji »

If I run setvol from the command line, it works fine. ...For example, "setvol 25".
If I run setvol from a batch file, the word "error" appears in red, and the volume does not change.
(Windows 7, 32-bit Service Pack 1)
RobLatour
Site Admin
Posts: 1003
Joined: Mon Feb 19, 2018 11:43 am

Re: Setvol not working from within batch filr

Post by RobLatour »

can you please attach your .bat file

I just ran a quick test, and it works for me. To test it, I create a file called c:\temp\test.bat with the following contents:

Code: Select all

c:
cd \
cd program files
cd setvol
setvol 25
pause
Kichiji
Posts: 3
Joined: Sun Aug 11, 2019 5:31 pm

Re: Setvol not working from within batch filr

Post by Kichiji »

Code: Select all

path
rem PATH=C:\Windows\system32;C:\Windows
%dstdir%\shadow\bin\setvol 27
rem above gives error
rem dstdir=d:
rem exe is fully pathed because d:\shadow\bin is not on the path.
rem exe executes but gives red "error" message.
setvol 27
rem above should not work, because setvol.exe is not on the path.
rem ...but it works!  ...And gives no error.  WTH?  (what the hey/heck)
pause
RobLatour
Site Admin
Posts: 1003
Joined: Mon Feb 19, 2018 11:43 am

Re: Setvol not working from within batch filr

Post by RobLatour »

I have my version stored in c:\program files\setvol
and with that, from the cmd prompt
"c:\program files\setvol\setvol" 27
returns an error
but
"c:\program files\setvol\setvol.exe" 27
works.

So I would suggest you replace
%dstdir%\shadow\bin\setvol 27
with
%dstdir%\shadow\bin\setvol.exe 27

please let me know if the fix to your batch file above works for you.

as to why setvol 27 works, it should not, unless you have setvol also stored in a directory on your path, or your batch file has the current directory pointed to where setvol resides.
Kichiji
Posts: 3
Joined: Sun Aug 11, 2019 5:31 pm

Re: Setvol not working from within batch filr

Post by Kichiji »

You are right. setvol 27 works because I am running the batch from a window that already has path set to d:\shadow\bin
If I retry the test from a fresh window, it gives the expected error...
'setvol' is not recognized as an internal or external command,
operable program or batch file.
This particular batch needs to work in any window, even those where the path has not been set, which is why I fully pathed it, as I mentioned before.
changing setvol to setvol.exe works, but it's still a puzzle.
I wrote a utility called waittill.exe, and...
d:\shadow\bin\waittill 11:18
...works fine.
So, now I can get my batch to work. Thank you. It just nags at my brain that setvol.exe works, but setvol doesn't.
RobLatour
Site Admin
Posts: 1003
Joined: Mon Feb 19, 2018 11:43 am

Re: Setvol not working from within batch filr

Post by RobLatour »

ok - glad its working for you. Gotta love Windows!
Post Reply