Autologin based on IP

Eventually, I’d like to set some displays out on the shop floor to display status. Would I be able to have these machines automatically log according to their (static) IP addresses, whist others, such as admins or supervisors would log in “normally”?

OT: I may have just doubled my post count today… :laughing:


Is it viable to create a separate project for the large screen displays that is set to autologon? You would then want to create a Windows shortcut to a full screen launch. This post describes it.


You can use a login script to do/not do something based on IP address/hostname. One approach to large screen displays uses a timed script to check the database for instructions periodically. This allows you to change the screen/sets of screens or settings remotely.

I’d like to keep things to a single Project, so here’s what I came up with:

You may have heard me mention AutoIt before to automate Windows tasks, and this is what I ran with.

Once it’s written and working the script can be compiled into an executable and ran with Windows login and startup policies. Easy to deploy, and keeps me down to one FPMI project to manage. :mrgreen:

For those interested in the AutoIt script:

[code]; AutoIt script to automate FPMI login without using the Project’s autologin feature

#include <IE.au3>

; Create IE instance to launch project

; Wait for Project window to open. This must match what is in the “Window Title” entry on the Project Management screen in the Gateway.

; Set focus to the project window

; Wait until project window is active. This is more of a CYA from the above command just in case there’s a bit of delay

; Send Keystrokes for username and password

Hope this can be of help to others.


I’ve come across Autoit before but I’ve never used it - it looks impressive.

I’ve come up with a method which keeps everything in a single project and still only uses standard FactoryPMI functions. Here’s how:

  1. Create 2 screens (here called Autostart1 and Autostart2), the first of which starts on the autologin nodes, the second on the nodes users have to enter their username and password.

  2. Set the project to login automatically in the Project Properties section of the gateway.

  3. Create a table in your database (here called Autostart) with a string field for your IP address and another boolean field (here called RunAlready). Here’s the create script for MySQL:DROP TABLE IF EXISTS `test`.`autostart`; CREATE TABLE `test`.`autostart` ( `IP` char(15) NOT NULL, `RunAlready` tinyint(1) NOT NULL, PRIMARY KEY (`IP`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;4. Put the following script in the Global Events Startup script:myIP = if myIP == "": fpmi.nav.openWindow("Autostart1") else: runAlready = fpmi.db.runScalarQuery("SELECT RunAlready FROM Autostart WHERE IP='%s'" % myIP) if runAlready == 0: fpmi.db.runUpdateQuery("UPDATE Autostart SET RunAlready=1 WHERE IP='%s'" % myIP) else: fpmi.db.runUpdateQuery("UPDATE Autostart SET RunAlready=0 WHERE IP='%s'" % myIP) fpmi.nav.openWindow("Autostart2")The script works as follows:

The node starts and logs in automatically. If its IP matches (and you can obviously check for as many as you wish) the Autostart1 picture will be opened.

If its IP doesn’t match, it will check to see whether the script has run already. If not, it sets the flags and logs the node out, presenting the standard login screen to the user. The user will log in and this time the script will see the flag set. It then resets the flag and displays Autostart2.

After playing with this I found a much cleaner way to do this;

  1. Setup a auto login user account the normal way. We call ours ‘AutoLogin’
  2. Turn on in the project preferences to auto login using the account created in step #1.
  3. In the Client startup script put the following code;
system.gui.messageBox(addr)               #Remove this when finished testing.

if addr == "":                     #This is the IPAddr you want to auto login to a known user'User','password')   #Set the user and password here
	system.gui.messageBox(user)                          #Remove this when finished testing
	if user == 'AutoLogin':

How this works is if the IP address matches, then just switch the user crenditials, otherwise the frist time in, there user name will be ‘AutoLogin’ or what every account you set up for the autologin. And it will log them out to the ignition login screen, but now they will enter what they really want to log in as. And since there a different user then ‘AutoLogin’ they will get in. No need to use a database to keep track of things.

1 Like

The reason to use the database was that we could have dozens of displays around the plant. In that instance, adding an IP address to the table is cleaner than multiple if…elif…else statements or a very long ORed condition. :wink:

Also, the table could carry individual login information and/or startup screen.

2009? I knew I didn’t have the time to develop an all around solution, but four years? :open_mouth: Man, the time does go by, doesn’t it?

I guess I did not explain very well what made it simpiler, there is no need for the flag bit. You could change the IP address for the DB query and it will still work.