Support forum

Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_TopicIcon
Script connector run a bat or exe file.
sp_NewPost Add Reply sp_NewTopic Add Topic
May 20, 2015
9:53 am
Henk Helmantel
Admin
Forum Posts: 1487
Member Since:
May 28, 2013
sp_UserOfflineSmall Offline

Hello Bruno,

Both methods you describe can be used to start a batch file or executable, but there are some points you should take into account that are specific to scripts in Diafaan SMS Server.

1. It is good practice to wrap all your code in a try..catch statements so that the script adds exception errors to the event log of Diafaan SMS Server:

try {
System.Diagnostics.Process.Start(@"c:\temp\batchfilename.bat");
}
catch (Exception e) {
PostEventLog(e.Message, e.ToString(), EventLog.Error);
}

2. By default, the Diafaan SMS Server service runs under the local system account. This account has limited rights and it might not have the rights to start you batch file in the folder where you placed it. You can either place the batch file to a location where the local system account can use it or change the startup account for the service in the Service Control Manager to a(n) (administrator) user with more rights.

3. It is also possible that you batch file is called but that it cannot execute the batch commands, either because Diafaan SMS Server does not have the proper rights or because the environment parameters are incorrect. You can add re-directions for the output of the batch commands as debug statements to see if the commands are executed correctly. E.g.:

echo Debug Line 1 >> "c:\temp\debug.txt"

Regards, Henk

May 19, 2015
6:26 pm
Bruno Roger
Guest
Guests

Hi,

Its possible when i receive one message, the script connector runs a bat or exe file?

I trying some things, but not happens.

____________________________

I'm put the code in "OnMessageReceived",
__________________________
I'm try this:

string command = @"C:\My Dir\MyFile.exe";
Process process = new Process();
process.StartInfo.FileName = command;
process.Start();
_____________________________
And this:

System.Diagnostics.Process.Start("c:\\batchfilename.bat");
_____________________________

The code compile without errors, but the file not execute.

Do you have any suggestion to resolve this ?

thx.

Forum Timezone: Europe/Amsterdam

Most Users Ever Online: 529

Currently Online:
6 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Member Stats:

Guest Posters: 671

Members: 0

Moderators: 0

Admins: 1

Forum Stats:

Groups: 2

Forums: 3

Topics: 1140

Posts: 3897

Newest Members:

, Henk Helmantel

Administrators: Henk Helmantel: 1487