Vbs code to get IP address on Siemens HMI MP277

perikooo

Member
Join Date
Aug 2006
Location
Mi Casa
Posts
1
Hello:

I have a proyect with 5 siemens MP277 screens over ethernet.

The problem is that those screens have to show different datas depending of their physical location.

One solution is to have 5 different proyects so each screen has to be loaded with the right one.

I don´t like it because i want to have only one proyect.

The idea is that this proyect has some code (visual basic script) that reads the IP address of the screen and depending of it, shows the correct data for that screen.

So, anyone knot if is it posible? Any other solution?

Thanks in advance

PS: Sorry for my bad english O:)
 
Because I couldn't find an answer:-
vIP,vMask, vMac, vHostname are internal string variables to receive the results.

Code:
' 20090518 Get the Ip Address and store it in Local Variables (From Siemens AG)
' Modified to work on Windows CE V5.0 on the MP277
Dim fso,f,temp,erg,t
Set fso = CreateObject("FileCtl.FileSystem")
Set f = CreateObject("FileCtl.File")
'writes the ipconfig in to a text file 
'Help says hmiShowMinimizedAndInactive, but program only accepts hmiShowMaximizedAndInactive
'Command for WinCCflexible/CE 5.0
StartProgram "CMD", "/C ipconfig /all >\Flash\ip.txt", hmiShowMinimized, hmiNo 
'wait until the output is ready
Do Until fso.Dir("\Flash\ip.txt") = "ip.txt" 
Loop
'open the text file
f.open "\Flash\ip.txt",1,1 'fsModeInput,fsAccessReadWrite 
Do
temp = f.LineInputString 'read out line by line
erg = InStr(temp, "IP Address ........ : ") 'wenn / if Zeile = IPAdresse
If erg Then 
SmartTags("vIP") = Right(temp,Len(temp)-erg-21)
End If
erg = InStr(temp, "Subnet Mask........ : ") 'wenn / if Zeile = SubnetMask
If erg Then SmartTags("vMask") = Right(temp,Len(temp)-erg-21)
erg = InStr(temp, "Address............ : ") 'wenn / if Zeile = MAC-Adresse
If erg Then SmartTags("vMac") = Right(temp,Len(temp)-erg-21)
erg = InStr(temp, "Host name.......... : ") 'wenn / if Zeile = HostName
If erg Then SmartTags("vHostName") = Right(temp,Len(temp)-erg-21)
Loop While f.EOF = False
f.Close 'close the text file
Set f = Nothing
Set fso = Nothing
 
Last edited:

Similar Topics

Hello, I just started learning WinCC V8.0 3 days ago, so I'm still new to how everything works in this program. I've created a pop-up with a...
Replies
2
Views
669
Hello. I am trying to do some basic file operations (move file from one folder to another, rename file in the new folder etc) and usually I just...
Replies
1
Views
2,179
Hello everyone. I'm trying to export data to excel from Wincc. My code is global action that executed every second that create excel filer per...
Replies
1
Views
5,716
Hi all. I am trying to write vbs code to copy data SQL from one server to another . i can write data to blockdata, but i cannot copy data from...
Replies
0
Views
1,666
Hello all, I have written a VBS script to read a group of tags, and put the values and tag name etc into a text file when I press a button on one...
Replies
1
Views
1,873
Back
Top Bottom