I want to bring to your attention a program that I wrote for the sake of experiment. The program is a system service that works with a GSM modem, is able to receive and send SMS messages. Depending on the text of the incoming message, calls the specified scripts and sends the response.
It may be useful, for example, to manage a server to which access is restricted (located on the company's internal network). Do not judge strictly, because rather, it is a prototype, the first version.
Download the program
here .
The program's archive contains several files: the program itself (SMSRC.exe), the installation file (options.ini), examples of ready-made scripts (the scripts folder).
')
IronIt should work with any GSM modem or cell phone that can be connected in GSM modem mode. To determine the port number on which the modem “hangs”, you need to go to the control panel, open the
Phone and modem panel on the Modems tab in the
Connected to column
to view the port number.
Setup and StartupBefore starting, you need to change the settings file (specify the port, at least register your numbers), make sure that no other programs running on the GSM modem are running on the computer.
To install the program as a service, you must run it with the
-install key. To uninstall from
-uninstall services. To start without adding to system services
-debug (it will not create windows at startup, for stopping you will have to kill through the process list).
The settings file is an ini file in which parameters for connecting to the device and message processing scripts are set.
[Settings]; Port number on which the modem hangsport = com8
rate = 115200
; Check interval in millisecondstimeout = 5000
The following are scripts. Consider one of these for example.
; In brackets the text of the incoming message[123]; Script pathscript = scripts \ cpuLoad.vbs
; Send reply. If the key is missing,; or its value is not equal to the unit, the answer will not be sentreply = 1
; The number to which the response should be sentreplyTo = 7917XXXXXXX
; Action allowed if the request came from one of the specified numbersallowedTo = 7917XXXXXXX, 7902YYYYYYY
If from the number 7917XXXXXXX or 7902YYYYYYY you receive a message with the text 123, the script cpuLoad.vbs will be executed and the answer will be sent to the number 7917XXXXXXXX
The cpuLoad.vbs script contains:
On Error Resume Next
Dim strComputer : strComputer = "."
Dim strResponse
Set objWMIService = GetObject( "winmgmts:\\" & strComputer & "\root\CIMV2" )
Set colItems = objWMIService.ExecQuery( "SELECT * FROM Win32_Processor" ,,48)
For Each objItem in colItems
strResponse = strResponse & "CPU load: " & objItem.LoadPercentage & "%" & vbCrLf
Next
Wscript.Echo strResponse
* This source code was highlighted with Source Code Highlighter .
The script, through WMI, receives information about the installed processors, for each of them determines the current load and returns the result via Wscript.Echo. This text will be sent by SMS.
Attention! Do not use the MsgBox script, when executing such a script, the program will wait for the script to complete, and the script, in turn, will close the message window.As an example, the archive also contains a script for determining the IP address of a connection to a local network and opening an mp3 file.
After launching, a debug.log file will be created in the program directory, which, in case of nonoperability, will be able to tell where to look for the cause.
For myself, I could not find a practical application of this program, since do not administer.
In the process of development I used only fun for the sake of (send a message to turn on the music, while puzzling the spouse, who at that time is sitting at the computer).
I would be glad if the program will be useful to anyone.
UPDA set of classes for receiving, sending SMS messages and an example of using source code in C ++ is
here. The idea is to work under any version of Windows.
UPD2 Added
-send key for sending SMS from the command line. Example:
SMSRC.exe -send XXXXXXXXXXX "from cmd line!"
Where XXXXXXXXXXX is the number to which the SMS should be sent.
At the moment, the program is working in the "pipe or jug" mode, i.e. it is impossible to start the program as a service and at the same time use it to send SMS from the command line. The first copy will open the COM port to which the modem is connected, and no one else will get access to the modem anymore. At the moment I am deciding how to allow one port to be used for several instances. How to decide - post update.