Wireless Profile push/automation

Hey guys, I’m really glad there is somewhere I can come for help. I don’t know anything about Applescript but I’m SO CLOSE! Quick idea, then problem.

Working at a location that has WPA2E wireless. I have setup the script so that it auto makes a new location and auto adds the profile. The problem we have is that people already have a new location or already have the profile so I need to delete it first before I add it.

Unfortunately the Applescript ends when it does not find the network. How can I have the applescript say ok fine and just continue on?


do shell script "/usr/sbin/networksetup -removepreferredwirelessnetwork en1 NETWORKNAME"
do shell script "/usr/sbin/networksetup -removelocation en1 LOCATIONNAME"
do shell script "/usr/sbin/networksetup -createlocation LOCATIONNAME populate"
do shell script "/usr/sbin/networksetup -switchtolocation LOCATIONNAME"
do shell script "/usr/sbin/networksetup -addpreferredwirelessnetworkatindex en1 NETWORKNAME 0 WPA2E"

If the NETWORKNAME in step one does not exist it fails and errors out. How do I get it to continue even with an error?

It will also fail on step 2 because the LOCATIONNAME might not exist.

Thank you guys so much in advance this is going to be so huge if I can get this working perfectly.

Try this (pun intended:D)

try
	do shell script "/usr/sbin/networksetup -removepreferredwirelessnetwork en1 NETWORKNAME"
end try
try
	do shell script "/usr/sbin/networksetup -removelocation en1 LOCATIONNAME"
end try
do shell script "/usr/sbin/networksetup -createlocation LOCATIONNAME populate"
do shell script "/usr/sbin/networksetup -switchtolocation LOCATIONNAME"
do shell script "/usr/sbin/networksetup -addpreferredwirelessnetworkatindex en1 NETWORKNAME 0 WPA2E"

Hank,

I just wanted to take the time to thank you. The script seems to be working great now. I’m going to test a few more things to see if I can get it to be exactly what we need. Thanks in advance I really appreciate the help.

Added a few more commands and really cleaned it up nice. As of right now it seems like it’s going to totally solve our problem. Thank you so much to everyone that helped me.

Glad to help micro23… good luck. :cool: