"batch file" for user-manager

I work in a Hotel Environment, and got user-manager working like a charm, creating tickets and all that - no problems there.

However I have situations, where I have large meetings on conferences, where instead of giving out tickets like it’s Christmas, I create one multi-logon user directly onto the Mikrotik’s Hotspot user list, and they use that for the events.

Creating one off myself is no big deal, however I’m getting bombarded by these requests weekly, and I have a lot on my plate, so to me it’s just an annoying waste of my time.

Is there a way where I can develop a simple file .. being Java, an MS-DOS batch file or something of the sort, that I can give to the Frontdesk people, and all they do is load it, give it a username, and the application talks to the Mikrotik and sends a:

/ip hotspot user add name=batman profile=multipleuser

That “simple”. Would make my life sooooo infinitely easier!

I do tinker in Java, but I’m far from a programmer, so the simpler I can get this done, the better :slight_smile:

Thanks.

Really? Nobody? :frowning:

I have done something similar using a batch file that asks for input and uploads a file.auto.rsc script via ftp to the router. Upon upload, the script is automatically executed. Downside is that router password would be in plain text in the batch file, and with some versions of RouterOS, there is a bug I ran into.

A second option would be creating a program in java/php/C/whatever using the API. Using this method you would have to turn on the API service on each router.

Another option would be to create a custom Webfig skin. They would have to log in via their browser to add the users.

I wouldn’t mind the password being in plain text.

The way things are set up, unless someone manages to breach Admin access on a domain level, I’ll be the only one to see it.

Because of the bug I mentioned earlier, the FIRST time this is run, it will not fully work. The script will be uploaded to the router, but it will not execute. Then, after that it will work every time (as long as the script.auto.rsc file exists on the router). MikroTIK confirmed this is a bug, and said they’ll fix it. I haven’t tested it in any later versions.
@echo off

:: CONFIG ::::::::::::::::::::::::::::::::::\

set user=username
set pass=password
set ip=192.168.0.1

:: END CONFIG ::::::::::::::::::::::::::::::confused:

:: Window Attributes
title HOTSPOT
mode CON: cols=40 lines=11

:: menu
echo.
echo ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
echo ± ±
echo ± ADD Hotspot User ±
echo ± ±
echo ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
echo.
echo.
for /f %%A in (‘“prompt $H &echo on &for %%B in (1) do rem”’) do set BS=%%A
set /p input=%BS% -^> Enter name:

:: mikrotik script
echo /ip hotspot user add name=“%input%” profile=multipleuser>script.auto.rsc

:: ftp commands to upload script
echo user %user%> ftp.dat
echo %pass%>> ftp.dat
echo put script.auto.rsc>> ftp.dat
echo quit>> ftp.dat

:: upload script
ftp -n -s:ftp.dat %ip%> NUL

:: cleanup
del /q ftp.dat
del /q script.auto.rsc

You sir, have my eternal gratitude!

Will give it a spin first thing on Monday, and report back :slight_smile:

Cool, let me know how it goes. One thing I realized after posting was that you might need to change the profile in the following line, in case it changes across routers:
echo /ip hotspot user add name=“%input%” profile=multipleuser>script.auto.rsc

Yes I figured that one out :slight_smile:

I got the jist of what’s happening in the batch file, so i’ll amend as necessary :slight_smile:

hello
Variations of this user (Batch) group in mikrotik to edit the page Signup?
hellp…

I think this bug was fixed, I can no longer use this trick to upload config