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
how to run .bat file in diafaan using vb.net
sp_NewPost Add Reply sp_NewTopic Add Topic
December 29, 2015
4:09 pm
Henk Helmantel
Admin
Forum Posts: 554
Member Since:
May 28, 2013
sp_UserOfflineSmall Offline

In VBScript, you can use 'WScript.Arguments' to get the arguments used when the script was called. For the VB.NET Scripting Connector script below, this would be:

If WScript.Arguments.Count >= 1 Then fromAddress = WScript.Arguments(0)
If WScript.Arguments.Count >= 2 Then message = WScript.Arguments(1)

Regards, Henk

December 29, 2015
1:39 pm
surykant
Guest
Guests

Thanks Henk,

can u tell me,how to use VBScript in vb.net code,

as i am using vbscript file in vb.net code,requirement is like, after receiving SMS, want to pass "message" as an argument/variable to the vbScript.

Regards,
Surykant

December 28, 2015
3:55 pm
Henk Helmantel
Admin
Forum Posts: 554
Member Since:
May 28, 2013
sp_UserOfflineSmall Offline

Hello surikant,

For a simple VB.NET script that calls batch file 'C:\temp\test.bat' with the from address and the message text as the arguments, you can replace the 'OnMessageReceived' method of the default script VB.NET with the following code, you also have to add the line 'Imports System.Diagnostics' to the import list at the top of the script:

Private Sub OnMessageReceived(fromAddress As String, toAddress As String, message As String, messageType As String, messageId As String, smsc As String, _
pdu As String, gateway As String, sendTime As DateTime, receiveTime As DateTime)
Try
Using proc As New Process
proc.StartInfo.FileName = "C:\temp\test.bat"
proc.StartInfo.Arguments = String.Format("""{0}"" ""{1}""", fromAddress, message)
proc.StartInfo.UseShellExecute = False
proc.StartInfo.RedirectStandardOutput = True
proc.StartInfo.CreateNoWindow = True
proc.Start()
Dim output As String = proc.StandardOutput.ReadToEnd()
End Using
Catch e As Exception
PostEventLog(e.Message, e.ToString(), EventLog.Error)
End try
End Sub

Regards, Henk

December 28, 2015
7:02 am
surykant
Guest
Guests

hi,
how to run batch scripts in diaffan using vb.net connector or if any other way??

Forum Timezone: Europe/Amsterdam

Most Users Ever Online: 494

Currently Online:
3 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Member Stats:

Guest Posters: 365

Members: 0

Moderators: 0

Admins: 1

Forum Stats:

Groups: 2

Forums: 3

Topics: 533

Posts: 1849

Newest Members:

, Henk Helmantel

Administrators: Henk Helmantel: 554