Play Another Song in a batch music player consecutively - windows

Good morning, I have written a batch script that plays a song on the click of a button, I have created a "playlist" that contains many songs, I wonder how to play a song after the previous one is finished...
The script used for the songs is this for all the songs:
:Song
set "file=Song.mp3"
( echo Set Sound = CreateObject("WMPlayer.OCX.7"^)
echo Sound.URL = "%file%"
echo Sound.settings.volume = 100
echo Sound.settings.setMode "loop", True
echo Sound.Controls.play
echo While Sound.playState ^<^> 1
echo WScript.Sleep 100
echo Wend
)>sound.vbs
start sound.vbs
echo Song>playing.txt
cls
goto start
The script writes the name of the song into a file called playing.txt which is used to let the script know if a song is being played and also know which one, and then perform other actions.
Here is an Example of the playlist using buttons:
:songs
cls
cmdMenuSel f870 "Song Number One - Author" "Song Number Two - Author" "Song Number Three - Author"
if %ERRORLEVEL% == 1 goto SongNumberOne
if %ERRORLEVEL% == 2 goto SongNumberTwo
if %ERRORLEVEL% == 3 goto SongNumberThree
:SongNumberOne
cls
set "file=SongNumberOne.mp3"
( echo Set Sound = CreateObject("WMPlayer.OCX.7"^)
echo Sound.URL = "%file%"
echo Sound.settings.volume = 100
echo Sound.settings.setMode "loop", True
echo Sound.Controls.play
echo While Sound.playState ^<^> 1
echo WScript.Sleep 100
echo Wend
)>sound.vbs
start sound.vbs
echo SongNumberOne>playing.txt
cls
goto start
:SongNumberTwo
cls
set "file=SongNumberTwo.mp3"
( echo Set Sound = CreateObject("WMPlayer.OCX.7"^)
echo Sound.URL = "%file%"
echo Sound.settings.volume = 100
echo Sound.settings.setMode "loop", True
echo Sound.Controls.play
echo While Sound.playState ^<^> 1
echo WScript.Sleep 100
echo Wend
)>sound.vbs
start sound.vbs
echo SongNumberTwo>playing.txt
cls
goto start
:SongNumberThree
cls
set "file=SongNumberThree.mp3"
( echo Set Sound = CreateObject("WMPlayer.OCX.7"^)
echo Sound.URL = "%file%"
echo Sound.settings.volume = 100
echo Sound.settings.setMode "loop", True
echo Sound.Controls.play
echo While Sound.playState ^<^> 1
echo WScript.Sleep 100
echo Wend
)>sound.vbs
start sound.vbs
echo SongNumberThree>playing.txt
cls
goto start
In the data folder There are a mp3 file that has the song name but formatted:
Song Number One = SongNumberOne.mp3
also have a .txt with the name of the song
SongNumberOne.txt
This for every song
The real problem is that i can't create a single batch file for every song, cause i'm gonna add more artist to the program, and i have some buttons plugin that brakes when opened by another batch file.
I thought there was an attribute for the VBS file or something.
Also how do the program know that the song is finished?
the only thing I can think of, and I think it's the only thing possible in less than a whole ice age is to synchronize the time of the song to the batch, when the timer expires, it goes to the next song, if you have something to recommend for that.
P.S. i'm new Here :)

Here is an example : on my test script i choose *.wav
You should modify two variables : The Path of your MusicFolder=folderpath\mp3files and the Extension : Ext=mp3
So the trick is to use the command Start with the switch /Wait in order to wait until the vbscript ends and so on ...
#echo off
Title Playing Music
Set "MusicFolder=%windir%\Media"
Set "Ext=wav"
Set "PlayedSong=%~dp0Played.txt"
If Exist "%PlayedSong%" Del "%PlayedSong%"
Set /a Count=0
SetLocal EnableDelayedExpansion
#for /f "delims=" %%a in ('Dir /S /B %MusicFolder%\*.%Ext%') do (
set /a count+=1
cls & echo( & echo [!Count!] - Playing "%%~nxa"
Call :Play "%%a"
Echo [!Count!] - "%%~nxa" is Played>>"%PlayedSong%"
)
Pause & exit
::----------------------------------------------------------
:Play <URL>
(
echo Play "%~1"
echo Sub Play(URL^)
echo Dim Sound
echo Set Sound = CreateObject("WMPlayer.OCX"^)
echo Sound.URL = URL
echo Sound.settings.volume = 100
echo Sound.Controls.play
echo While Sound.playState ^<^> 1
echo WScript.Sleep 100
echo Wend
echo End Sub
)>"%Temp%\%~n0.vbs
Start "%~nx1" /wait wscript "%Temp%\%~n0.vbs"
Exit /b
::----------------------------------------------------------
EDIT: Or if you want to show as Menu with a numbred files :
So the user can type PlayAll in order to play all media files found here "%MediaFolder%" consecutively ...
Or he can type only the number of file that he wants to play ...
#echo off
Title Playing some media's files from "%windir%\Media" folder
Set "MediaFolder=%windir%\media"
Set "Ext=*.wav *.mp3"
cd /d "%MediaFolder%"
setlocal enableDelayedExpansion
REM Count total wav's and store into array
set /a "Count=0"
#for %%f in (%Ext%) do (
set /a "Count+=1"
set "list[!Count!]=%%f"
)
::---------------------------------------------------------------------------------
:Display_Results
cls
#for /L %%a in (1,1,%Count%) do (
echo( [%%a] - "!list[%%a]!"
)
Echo( -----------------------------------------------------------------------------
Echo( Total Media's files found are equal to %Count% on this folder : "%MediaFolder%"
Echo( -----------------------------------------------------------------------------
echo(
If [%Count%] EQU [0] color 0C & echo( There are No Media Files found in this Folder "%MediaFolder%" & TimeOut /T 10 /NoBreak>nul & Exit /B 1
echo( Type "PlayAll" In Order to play all media files found here "%MediaFolder%" consecutively ...
echo( Or Type only the number of file that you want to play ...
set /p "Input="
cls
#For /L %%i in (1,1,%Count%) Do (
If "%INPUT%" EQU "%%i" (
Echo( [%%i] - Playing "!list[%%i]!"
Call :Play "!list[%%i]!"
)
If /I "%Input%" == "playall" (
Echo( [%%i] - Playing "!list[%%i]!"
Call :Play "!list[%%i]!"
)
)
Goto Display_Results
::---------------------------------------------------------------------------------
:Play <URL>
(
echo Play "%~1"
echo Sub Play(URL^)
echo Dim Sound
echo Set Sound = CreateObject("WMPlayer.OCX"^)
echo Sound.URL = URL
echo Sound.settings.volume = 100
echo Sound.Controls.play
echo While Sound.playState ^<^> 1
echo WScript.Sleep 100
echo Wend
echo End Sub
)>"%Temp%\%~n0.vbs
Start "%~nx1" /wait wscript "%Temp%\%~n0.vbs"
Exit /b
::----------------------------------------------------------------------------------

Related

File bat search date in csv file

OK thanks for all information , I change my CVS in :
NUMBER;CITY;SERVER;NUMBER1;NUMBER2;EMAIL;ADDRESS
3;3 - NEW YORK;192.168.1.10;32049586848;032059684749;pippo#vision.de;Mießtaler Straße 12 A-9020 Klagenfurt
4;4 - Rome;192.168.1.22;345689768;0234567890;pluto#vision.uk;Via Platani 00133 22 Rome
and I changed the code like this :
#echo off
cls
setlocal enabledelayedexpansion
set CSVFILE=test.csv
:HOME
cls
set column=""
echo TEST
echo 1 Search IP
echo X Close
echo.
Choice /C 1X /N /M "Please make a selection: "
echo.
IF ERRORLEVEL 2 GOTO :EXIT
IF ERRORLEVEL 1 GOTO :IP
:IP
set column=SERVER
echo ---- Enter IP ----
set /p strsearch=
cls
GOTO :FINDIT
:FINDIT
for /f "skip=1 tokens=*" %%A in (%CSVFILE%) do (
set inline=%%A
for /f "tokens=1-7 delims=;" %%1 in ("!SERVER!") do (
set "NUMBER=%%~1" & set "CITY=%%~2" & set "SERVER=%%~3" & set "ADDRESS=%%~7"
if /I "!%column%!" equ "%strsearch%" GOTO :SHOW
)
)
:NFOUND
echo NOT FOUND Try AGAIN
pause
GOTO :HOME
:SHOW
echo SERVER: %SERVER%
echo Number: %NUMBER%
echo City: %CITY%
echo Address: %ADDRESS%
pause
GOTO :Home
:EXIT
Should it work now? What do you think about it ?
I can use csv files and bat files, i cannot use power shell on this system.
I have a file CSV :
NCITY;SERVER;NUMBER1;NUMBER2;EMAIL;ADDRESS
3 - NEW YORK;192.168.1.10;32049586848;032059684749;pippo#vision.de;Mießtaler Straße 12 A-9020 Klagenfurt
4 - Rome;192.168.1.22;345689768;0234567890;pluto#vision.uk;Via Platani 00133 22 Rome
I would like to create a bat file that, given an IP, shows me the corresponding number, name and address on the screen.
I was thinking of using this as a base script:
#echo off
cls
setlocal enabledelayedexpansion
set CSVFILE=test.csv
:HOME
cls
set column=""
echo TEST
echo 1 Search IP
echo X Close
echo.
Choice /C 1X /N /M "Please make a selection: "
echo.
IF ERRORLEVEL 2 GOTO :EXIT
IF ERRORLEVEL 1 GOTO :IP
:IP
set column=SERVER
echo ---- Enter IP ----
set /p strsearch=
cls
GOTO :FINDIT
:FINDIT
for /f "skip=1 tokens=*" %%A in (%CSVFILE%) do (
set inline=%%A
for /f "tokens=1-5 delims=," %%1 in ("!SERVER!") do (
set "SERVER=%%~1" & set "fname=%%~2" & set "comp=%%3" & set "cit=%%4" & set "stat=%%5"
if /I "!%column%!" equ "%strsearch%" GOTO :SHOW
)
)
:NFOUND
echo NOT FOUND Try AGAIN
pause
GOTO :HOME
:SHOW
echo SERVER: %SERVER%
echo Number: %lname%,%fname%
echo City: %cit%
echo Address: %stat%
pause
GOTO :Home
:EXIT
Can you help me fix it?
I haven't used bat files for a long time
thanks
Ok. So, you can't use PowerShell. Perhaps you should wonder why? Please do not consider this an answer for your question. However, someone else might benefit from it.
Using PowerShell for interactive console apps is a bit of underkill for PowerShell's capabilities. But, it can do it. And, it is already on your supported Windows system; nothing additional to install.
Save this in a file named Find-FromServerCsv.ps1
Run it in a PowerShell console using .\Find-FromServerCsv
Run it in a cmd.exe console using powershell -NoLogo -NoProfile -File ".\Find-FromServerCSV.ps1"
[CmdletBinding()]
Param()
$CsvFile = '.\csvpick.txt'
$Title = "Welcome"
$Info = "Just to Demo Promt for Choice"
$options = [System.Management.Automation.Host.ChoiceDescription[]] #('&Search by IP', '&Exit')
[int]$defaultchoice = 1
$opt = $host.UI.PromptForChoice($Title , $Info , $Options,$defaultchoice)
switch($opt) {
0 {
Write-Verbose 'doing search by IP'
$IpAddress = Read-Host -Prompt 'Please enter the IP address: '
Import-Csv -Path $CsvFile -Delimiter ';' |
Where-Object { $_.SERVER -eq $IpAddress } |
Select-Object -Property NUMBER1,NCITY,ADDRESS
}
1 {
Write-Verbose 'doing exit'
}
}

How to require user to activate my program?

I was wondering...
I have a program, and I want to charge money for it.
it runs on Windows, and is written mostly in VB and Batch-files...
how can I force the user to buy a product key for it, and activate it to use the Paid Version?
Thanks in advance!
~ #Cascading-style
This just a little example showing you that you can limit the number of execution of your program , so if the maximum of number of execution is reached the program will Auto delete by him self
#echo off
Setlocal enabledelayedexpansion
Title Count the number of times my BATCH file is run
Mode Con Cols=70 lines=7 & color 0E
Set /a MaxExecution=3
set /a count=1
set "FileCount=%tmp%\%~n0.dll"
If Not exist "%FileCount%" (
echo !count! > "%FileCount%"
) else (
For /F "delims= " %%a in ('Type "%FileCount%"') Do (
set /a count=!count! + %%a
echo !count! > "%FileCount%"
)
)
echo.
echo This Program is running for "!count!" time(s)
Call :SelfDelete
pause>nul & Exit /b
::**************************************************************
:SelfDelete
echo.
If !count! GTR !MaxExecution! (
Color 0C
echo The maximum execution of this "%~nx0" is set to "!MaxExecution!"
echo and it is reached & Timeout /T 5 /Nobreak>nul & Del %~f0
) else (
echo The counting is "!count!" and the max is set to "!MaxExecution!"
)
Goto :EOF
::**************************************************************

Unable to load a .cmd from a batch file

I recently played the game "Dictator" and wanted to recreate it in a batch script. I just began creating it when I ran into an issue. I have made programs which allow the user to save their progress and load it. I copied this code from a different program and put it in mine. Saving does seem to work but when i edit the save file (.cmd) and edit one of the saved variables, once I load that file nothing seems to happen. For example I saved one file called key.cmd and edited it to make the "pol" variable equivalent to 100. Once I loaded that file it did say loaded but the pol variable was still set to the default (10). I dont understand as I have made a folder called save and key.cmd file is inside it. I have used my save and load code multiple times in the past and have never had any issues. Please help! Here is my code:
:Setup
#echo off
title Dictator
color 0a
:Save Variables
set pol=10
set bui=10
set low=10
set cor=10
set peo=10
set cri=10
:Main
cls
echo 1 - Save
echo 2 - Load
echo 3 - Police - %pol%
echo 4 - Buissnes Men - %bui%
echo 5 - Lower Government - %low%
echo 6 - Corruption - %cor%
echo 7 - People - %peo%
echo 8 - Criminals - %cri%
choice /c 12345678 /n /m ">>> "
if %errorlevel% equ 1 goto Save
if %errorlevel% equ 2 goto load
:Save
cls
set /p pin="PIN: "
(
echo set pol=%pol%
echo set bui=%bui%
echo set low=%low%
echo set cor=%cor%
echo set peo=%peo%
echo set cri=%cri%
) >> saves\%pin%.cmd
echo SAVED
pause >nul
goto main
:Load
cls
set /p pin="PIN: "
if exist saves\%pin%.cmd (
call saves\%pin%.cmd
echo %pol%
echo LOADED
pause >nul
) else (
echo INCORRECT PIN
pause >nul
)
goto main
At :Load you need to allow spaces in the file name. Most users won't know of this weakness, but in order to allow spaces (and a few other 'special' characters) to be read in the user input without breaking it, you need to add setlocal enableextensions enabledelayedexpansion to the beginning of your batch file and make the set /p pin="PIN: " statement into set /p "pin=PIN: " and replace the %'s with !'s where it calls for %pin%.
In the end, your code should look like:
:Setup
setlocal enableextensions enabledelayedexpansion
#echo off
title Dictator
color 0a
:Save Variables
set pol=10
set bui=10
set low=10
set cor=10
set peo=10
set cri=10
:Main
cls
echo 1 - Save
echo 2 - Load
echo 3 - Police - %pol%
echo 4 - Buissnes Men - %bui%
echo 5 - Lower Government - %low%
echo 6 - Corruption - %cor%
echo 7 - People - %peo%
echo 8 - Criminals - %cri%
choice /c 12345678 /n /m ">>> "
if %errorlevel% equ 1 goto Save
if %errorlevel% equ 2 goto load
:Save
cls
set /p "pin=PIN: "
(
echo set pol=%pol%
echo set bui=%bui%
echo set low=%low%
echo set cor=%cor%
echo set peo=%peo%
echo set cri=%cri%
) >> saves\!pin!.cmd
echo SAVED
pause >nul
goto main
:Load
cls
set /p "pin=PIN: "
if exist saves\!pin!.cmd (
call saves\!pin!.cmd
echo %pol%
echo LOADED
pause >nul
) else (
echo INCORRECT PIN
pause >nul
)
goto main

Manipulate cmd ping color based on time

My internet is not always working properly and I'd like to check the quality based on the cmd windows tool. I believe it's a task simple enough for it to handle.
I've begun by making a shortcut so I can have easy access to the command:
C:\Windows\System32\PING.EXE 8.8.8.8 -t
Now I was trying to transform the cmd ping command into a visually responsive one based on the output. I'd like to make the color change according to the time response.
After looking and not finding anything related, I believe it's either impossible or no one has ever tried.
Thank you very much :)
PD: (In case there was anything unclear just ask and I'll gladly answer)
Based on Magoo's post, I wrote this little batch program.
It asks for the target, the number of requests to make, the max time allowed and the time between requests and then prints in red if the request is over the time max, otherwise it sums the number of requests. It includes timestamp to be more accurate.
Copy and paste in a text file and name it with extension ".bat" (But don't name it "ping.bat" otherwise the program will enter in an infinite loop).
REM CMD PING TOOL
REM By Daweb
REM https://stackoverflow.com/users/3779294/daweb
#ECHO OFF
REM Needed for Line colored
SETLOCAL EnableDelayedExpansion
FOR /F "tokens=1,2 delims=#" %%a IN ('"PROMPT #$H#$E# & echo on & for %%b in (1) do rem"') do (
SET "DEL=%%a"
)
for /f %%a in ('copy /Z "%~f0" nul') do set "CR=%%a"
ECHO *****************
ECHO * CMD PING TOOL *
ECHO *****************
REM Start
:start
ECHO.
ECHO Set yours values
REM SET Target
SET /p hostInput=" - Target (ip or hostname): "
If "%hostInput%"=="" ECHO.&GOTO start
REM SET loops
SET /p loopsInput=" - Requests number: "
SET /a loops=loopsInput
REM SET time limit
SET /p maxmsInput=" - Maximum Time Limit (ms): "
SET /a maxms=maxmsInput
REM Value used for sleep between loops
SET /p sleepInput=" - Delay between requests (s): "
SET /a sleepDelay=sleepInput+1
REM Variables
SET displayText=""
SET /a countRequestsOk=0
SET /a countRequestsKo=0
SET /a totalRequests=0
SET /a maxTime=0
ECHO.
ECHO START at %TIME% [target: %hostInput%, requests: %loops%, time limit: %maxms% ms, delay: %sleepInput% s]
ECHO.
REM Loop
:loop
REM Set time
FOR /f "tokens=1-3 delims=/:" %%a IN ("%TIME%") DO (SET mytime=%%ah%%bm%%cs)
REM Get ping value
FOR /f "tokens=3delims==" %%a IN ('PING -n 1 %hostInput%') DO FOR /f "delims=m" %%b IN ("%%a") DO (
SET /a timems=%%b
SET /a totalRequests+=1
REM Check result
IF !timems! GTR %maxms% ( GOTO failed ) ELSE ( GOTO success )
)
REM Request success
:success
SET /a countRequestsOk+=1
IF !timems! GTR !maxTime! ( SET /a maxTime=timems )
<nul set /P "=!countRequestsOk! requests [Max !maxTime! ms]!CR!"
GOTO next
REM Request failed
:failed
IF !countRequestsOk! GTR 0 ECHO.
SET /a countRequestsOk=0
SET /a countRequestsKo+=1
SET displayText=" %mytime% - !timems!ms"
CALL :ColorText 0c !displayText!
GOTO next
REM Next loop
:next
REM Sleep a little bit
IF %sleepDelay% GTR 1 ( ping -n %sleepDelay% localhost > nul )
REM Check continue
SET /a loops-=1
IF %loops% gtr 0 GOTO loop
REM Display result
IF !countRequestsOk! GTR 0 ECHO.
ECHO.
ECHO STOP at %TIME%
ECHO.
if !countRequestsKo! GTR 0 (
SET displayText="FAILED - !countRequestsKo! requests over %maxms% ms on !totalRequests! requests in total"
CALL :ColorText 0c !displayText!
) ELSE (
SET displayText="SUCCESS - No request over %maxms% ms on !totalRequests! requests in total"
CALL :ColorText 02 !displayText!
)
REM Ask if restart
ECHO.&ECHO *********************
SET /p restartInput="Do it again ? (Y/N): "
If "%restartInput%"=="" ECHO *********************&GOTO start
If /I "%restartInput%"=="y" ECHO *********************&GOTO start
If /I "%restartInput%"=="n" ECHO *********************&GOTO end
REM End
:end
PAUSE
GOTO :EOF
REM Line color
:ColorText
ECHO off
ECHO %DEL% > "%~2"
FINDSTR /v /a:%1 /R "^$" "%~2" NUL
DEL "%~2" > NUL 2>&1
#ECHO OFF
SETLOCAL
SET loops=10
:loop
FOR /f "tokens=3delims==" %%a IN ('PING 8.8.8.8 -n 1') DO FOR /f "delims=m" %%b IN ("%%a") DO ECHO %%b&COLOR %%b&GOTO cchgd
:cchgd
PAUSE
SET /a loops-=1
IF %loops% gtr 0 GOTO loop
COLOR
GOTO :EOF
A simple demonstration - repeats the ping 10 times, changing colours depending on the response. Manipulate to do as you wish...
I am not sure that I know what the desired output should be, but this will output GREEN text for response times 0-39 ms, YELLOW for 40-79 ms, and RED for 80+ ms.
Run this from a cmd.exe prompt using the following command or put it into a .bat file script. Change the directory to the location where the Get-PingColor.ps1 file is landed.
powershell -NoLogo -NoProfile -File "%USERPROFILE%\bin\Get-PingColor.ps1"
=== Get-PingColor.ps1
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[string[]]$ComputerNames
,[Parameter(Mandatory=$false)]
[int]$Count = 4
,[Parameter(Mandatory=$false)]
[int]$SpeedMinimumSlow = 80
,[Parameter(Mandatory=$false)]
[int]$SpeedMinimumMedium = 40
)
foreach ($ComputerName in $ComputerNames) {
$Pings = Test-Connection -ComputerName $ComputerName -Count $Count
$Average = ($Pings | Measure-Object -Property responsetime -Average).Average
$ForegroundColor = 'Green'
if ($Average -ge $SpeedMinimumSlow) { $ForegroundColor = 'Red'}
else { if ($Average -ge $SpeedMinimumMedium) { $ForegroundColor = 'Yellow' }}
Write-Host -ForegroundColor $ForegroundColor -BackgroundColor 'Black' "$ComputerName $Average ms"
}
=== Execution examples
I am loathe to put images into a post, but I do not see a way to produce color on SO.

multiple windows to 1 single window batch

I have 2 batch files I want to merge from 2 screens to 1 screen.
currently there is 2 screens:
1 screen is the chat room
1 screen is the message input screen.
I want to merge these into 1 batch file on the screen so it requests users input on the chat room screen
is that possible?
My code I want to merge is here:
----------------------------
chat.bat
----------------------------
#echo off
:StartUp
set rr=2
mode con cols=40 lines=8
if exist tmp.bat del /f /s /q tmp.bat
set hd=%cd%
title Remote Chat
color 0f
cls
echo [Remote Chat]
echo.
echo Made by Jordan Begg
echo 31/12/2013
set t1=%time:~6,2%
set /a t2=%t1%+2
if %t2% geq 60 set /a t2=%t2% - 59
:ExpLoop
if %time:~6,2% geq %t2% goto Go
goto ExpLoop
:Go
set cs=ChatSettings.bat
if exist %cs% (
call %cs%
goto Main
) else (
goto SetUp
)
:SetUp
cls
mkdir "C:\chat"
echo [Setup]
echo.
set /p un=Username:
if not defined un goto SetUp
:SetUp2
cls
echo [Setup]
echo.
echo Use this:
echo C:\chat
if defined sd echo Current: %sd%
echo.
set /p sd=Server folder:
if not defined sd goto SetUp2
set sd=%sd%
if not exist %sd% (
set sd=
echo Folder doesn't exist!
pause >nul
goto SetUp2
)
if exist %cs% del /f /s /q %cs%
echo set un=%un%>>%cs%
echo set sd=%sd%>>%cs%
echo set rr=4>>%cs%
goto Main
:Main
cd %hd%
cls
echo [Remote Chat]
echo.
echo 1 - Join
echo 2 - Create
echo 4 - Exit
echo.
set /p c=
if %c%==1 goto Join
if %c%==2 goto create1
if %c%==4 goto Exit
goto main
:Exit
exit
:create1
cls
echo Please enter a valid asset ID (i.e as0123456)
set /p ass=Asset:
ping -n 1 %ass% > c:\ping.tmp
type c:\ping.tmp | FIND "Approximate round trip" >NUL
IF ERRORLEVEL 1 GOTO NOPING
goto Create
:noping
echo Asset cannot be reached
echo.
goto create1
:Create
cd %sd%
set rn=
cls
echo [Create]
echo.
echo created
echo.
set rn=%ass%
echo %rn%
pause
if not defined rn goto Create
set rf=%sd%\%rn%.crm
if exist %rf% goto Create
cls
echo [Create]
echo.
echo Preparing room, please wait.
set group=Admin
echo [%time:~0,5%] %un% (admin) connected.>>%rf%
title Chat [%rn%]
cd %hd%
echo set rn=%rn%>>tmp.bat
echo set rf=%rf%>>tmp.bat
echo set group=%group%>>tmp.bat
start ChatMessage.bat
start ChatDisconnect.bat
cd %sd%
mode con cols=40 lines=16
:Admin
cls
cd %hd% >nul
if not exist tmp.bat (
set msg=Room closed successfully.
goto End
)
cd %sd% >nul
if not exist %rf% (
set msg=Connection terminated.
goto End
)
type %rf%
ping localhost -n 4 >nul
goto Admin
set t=%time:~7,1%+%rr%
if %t% GEQ 10 set /a t=%t% - 10
:AdminL
if %time:~7,1%==%t% goto Admin
:End
if exist tmp.bat del /f /s /q tmp.bat
mode con cols=40 lines=8
echo [Chat]
echo.
echo %msg%
set msg=
taskkill /f /fi "WINDOWTITLE eq Message" >nul
taskkill /f /fi "WINDOWTITLE eq Disconnect" >nul
title Chat
set group=
set rn=
set t1=%time:~6,2%
set /a t2=%t1%+2
if %t2% geq 60 set /a t2=%t2% - 5
:EndLoop
if %time:~6,2% geq %t2% goto Main
goto EndLoop
:Join
mode con cols=40 lines=16
cd %sd%
set rn=
cls
echo [Join]
echo.
if not exist %sd%\*crm (
echo No rooms available.
pause >nul
mode con cols=40 lines=8
goto Main
)
dir /b /o:n %sd%\*.crm
echo.
echo Format (no .crm at end): Room
set /p rn=Room's name:
if not defined rn goto Join
set rf=%sd%\%rn%.crm
if not exist %rf% goto Join
cls
echo [Join]
echo.
echo Joining room, please wait.
set group=User
echo [%time:~0,5%] %un% connected.>>%rf%
title Chat [%rn%]
cd %hd%
echo set rn=%rn%>>tmp.bat
echo set rf=%rf%>>tmp.bat
echo set group=%group%>>tmp.bat
start ChatMessage.bat
start ChatDisconnect.bat
cd %sd%
:User
cls
cd %hd% >nul
if not exist tmp.bat (
set msg=Disconnected successfully.
goto End
)
cd %sd% >nul
if not exist %rf% (
set msg=Connection terminated.
goto End
)
type %rf%
ping localhost -n 4 >nul
goto User
.
-----------------------
chatmessage.bat
------------------------
#echo off
if not exist tmp.bat (
exit
) else (
call tmp.bat
call ChatSettings.bat
)
title Message
mode con cols=30 lines=2
cd %sd%
:func
cls
set /p msg=Message:
if %msg:~0,3%==/me echo [%time:~0,5%] %un% %msg:~4%>>%rf%&& goto func
if not defined msg goto func
echo [%time:~0,5%] %un%: %msg%>>%rf%
goto func

Resources