PDA

View Full Version : A couple of handy batch files I made


FutureGameDevs
19-05-2008, 11:14
Hello Teamspeak Community,

I am new to this forum so I would like to say hello and offer you a little forum warming gift. I have developed a couple of interesting batch programs to do several things with teamspeak. I have found these useful and thought maybe others might also. I have named them as follows feel free to call them whatever you like.

viewCommands.bat
tsControl.exe
pause

outputCommands.bat
echo get_players and get_speakers... > info.txt
tsControl.exe get_players >> info.txt
tsControl.exe get_speakers >> info.txt
echo _____________________________ >> info.txt
echo get_client_version >> info.txt
tsControl.exe get_client_version >> info.txt
echo _____________________________ >> info.txt
echo get_server_info >> info.txt
tsControl.exe get_server_info >> info.txt
echo _____________________________ >> info.txt
echo get_user_info >> info.txt
tsControl.exe get_user_info >> info.txt
echo _____________________________ >> info.txt
echo get_channels >> info.txt
tsControl.exe get_channels >> info.txt

I am running both of these in the client_sdk directory of my teamspeak client installation directory.

But this is not all. Heh not by far. ;)

I have also built a full auto connection batch software suite.
This allows you to click a single icon and connect with preferred credentials. I have got it working very well on my system. It also includes an auto server. both of which with the help of process-viewer have error checking which only allows one ts program (either server or client) to run so there are no mistakes of accidentally running more then a single instance.

First you will need to acquire "pv.exe" it comes packaged with the utility software known as process-viewer. This handy freeware program is used in the process of checking for the running process. heh

link to process-viewer
http://www.faratasystems.com/pview/prcview.htm

once you have pv.exe by itself put it in a folder and call it something like "auto teamspeak" it doesn't matter what you call it as long as you remember where it is. Now here are my batch files.

run.bat
@echo off
autoclient.bat HostAddress "UserName" LoginName PassWord

replace HostAddress, UserName, LoginName, and PassWord with the appropriate information but for now you can leave that because I'll show you how to edit this very quickly in the future.

autoclient.bat
@echo off

echo Checking for existing process...
pv.exe TeamSpeak.exe > nul
if ERRORLEVEL 1 goto Process_NotFound


:Process_Found
echo Existing process detected...
echo Attemping Connection...
echo connecting to %1 with username: %2 loginname: %3 password: %4 on channel: default
cd %PROGRAMFILES%\Teamspeak2_RC2\client_sdk\
tsControl.exe connect TeamSpeak://%1/nickname=%2?loginname=%3?password=%4?channelname=
goto END

:Process_NotFound
echo Existing process not detected...
echo starting TeamSpeak.exe...
cd %PROGRAMFILES%\Teamspeak2_RC2\
start TeamSpeak.exe

echo Waiting 4 seconds for program to finish loading
echo Wscript.Sleep 4000 > sleep.vbs
start /w wscript.exe sleep.vbs
echo Done!
del sleep.vbs

echo Attemping Connection...
echo connecting to %1 with username: %2 loginname: %3 password: %4 on channel: default
cd %PROGRAMFILES%\Teamspeak2_RC2\client_sdk\
tsControl.exe connect TeamSpeak://%1/nickname=%2?loginname=%3?password=%4?channelname=
goto END

:END



if anyone knows a better way then this please comment.. notice the vb script to allow the application to start properly.

and now for the server.


server.bat
@echo off

echo Checking for existing process...
pv.exe server_windows.exe > nul
if ERRORLEVEL 1 goto Process_NotFound

:Process_Found
echo Process is running
goto END

:Process_NotFound
echo Process is not running
cd %PROGRAMFILES%\Teamspeak2_RC2\
start server_windows.exe
goto END

:END

this will only work with the current directories if you have installed teamspeak to it's default location however if you have the drive letter makes no difference as long as you have default environment values like %programfiles%.

Final Step: put all these files in the same folder as pv.exe THEN put that folder in the base teamspeak directory. next create shortcuts by right clicking run.bat and server.bat and choosing sent to->desktop shortcut

now rename your shortcuts and make sure the target directory is in your auto teamspeak folder. you can use the teamspeak executables to obtain nice icons for your shortcuts. remember I said you could edit them easily? easy just right click a shortcut and choose "edit".

Congratulations you now have a fully operational auto connection batch software suite just like me. pretty cool huh? :cool:

phew... this was a lot of work lol. it was nice meeting you aswell. ;)