VLC startup script and read host
brucine Posted messages 24686 Registration date Status Member Last intervention -
Hello everyone,
I'm having a bug...
I made a very simple little script to launch VLC at startup.
This will be placed in the startup folder to launch at startup.
Except that I want VLC to launch only when the Enter key is pressed when the PC starts.
So I thought of "read Host" in PowerShell.
I tested the "read-host" command and it works well.
The command to launch VLC works fine.
But the two together give me:
PS U:\> c:\VLC.bat
U:\>Read-Host "Press ENTER to continue..."
'Read-Host' is not recognized as an internal
or external command, an executable program or a batch file.
U:\>start vlc C:\DATA\film\intouchables.avi
PS U:\>
My really basic script:
Read-Host "Press ENTER to continue..."
start vlc C:\DATA\film\intouchables.avi
Where did I mess up?
Thanks in advance,
PS: I posted my post in the programming forum because I didn't really know where to put it, don't mock me. :-)
2 answers
Hello,
It's cheese or dessert: a PowerShell command is executed from a ps1 file, not from a bat/cmd file, unless we deceive the enemy with a syntax like:
powershell.exe -command "& { My command }"
We might be quicker to write something like:
CHCP 65001>NUL
ECHO "Press Enter to launch VLC"
pause
START...
Thank you very much.
In fact, renaming the file to PS1 works :-) Did I mention that I'm a bit ditzy?
Now I just need to try to create a loop so that the movie restarts every time you press enter.
The enter key will be simulated by a push button.
Little by little...
I'll leave it to the cat, I practice PowerShell little and the necessary looping since it doesn't have a GOTO label like Batch does, but this last one isn't necessarily simple either, because you have to call it only when the movie is playing, thus controlling whether the VLC process is finished or not.