ProTip: AppleScript is lame.

Printer add script to add AD printers on off domain Macs:

(*
	"Printer Add Script for domain printers" by mikesyr at gmail.com
	 v .07 Alpha Released 06/08/06
 
	This script should only be ran once for each printer that the users needs. This is more of a helper script for Techs than it is for users do themselves, although the user will need to be present to supply username and password. The tech should supply the EXACT printer name on the Windows printserver. If there are any mistakes in the user/pass or printer name, then the setup will NOT work. Another caveat is that this script uses the generic laserjet.ppd. 
 
	 This script is generally just another attempt at saving time. 
*)
 
property FirstTryPWD : true
set FirstTryPWD to true
 
--Setting some variables
tell application "Finder"
	display dialog "Enter Your Username:" default answer ""
	set User to the text returned of the result
	display dialog "Enter Your Password:" default answer "" with hidden answer
	set Pass to the text returned of the result
	--this portion sets the printer. this has to match the exact name of the printer on the printserver
	display dialog "Enter the printer name you wish to add:" default answer ""
	set Printer to the text returned of the result
end tell
 
--connect printer
try
	do shell script "lpadmin -p " & Printer & " -v smb://DOMAIN/" & User & ":" & Pass & "@printserver.address.com/" & Printer & " -m laserjet.ppd -E"
end try
delay 1
tell application "Finder"
	display dialog "You have added the " & Printer & " printer." buttons {"Ok"}
end tell

PPTPVPN-SMB-Connection Script-v.04:

(*
	"PPTP VPN & SMB Connection Script" by mikesyr at gmail.com
	 v .04 Alpha Released 08/10/06
 
	 Notes: 
 
		It has only been tested on Tiger.
 
	 	The script also prompts for username and password, saves them as variables and uses them to mount the shares. 
*)
 
 
 
 
--Connect to VPN with Internet Connect
 
 
tell application "Finder"
 
	-- Setting some variables
	display dialog "Enter Your Username:" default answer ""
	set User to the text returned of the result
	display dialog "Enter Your Password:" default answer "" with hidden answer
	set Pass to the text returned of the result
end tell
 
tell application "Internet Connect.app"
	«event netcconn» «class cnfg» "VPN (PPTP)" given «class user»:User, «class addr»:"vpn.server.address.edu", «class pass»:Pass
	repeat until «class RAsc» of «class RSst» of «class cnfg» "VPN (PPTP)" is greater than 3
	end repeat
	quit
end tell
 
tell application "Finder"
 
	-- Setting some more variables
	set Share4 to "smb://DOMAIN;" & User & ":" & Pass & "@address.to.users.home.drive/" & User & "$"
	set Share1 to "smb://DOMAIN;" & User & ":" & Pass & "@share1.com/share1"
	set Share2 to "smb://DOMAIN;" & User & ":" & Pass & "@share2.com/share2"
	set Share3 to "smb://DOMAIN;" & User & ":" & Pass & "@share3.com/share3"
 
 
 
	--Mounting the drives
	try
		mount volume Share4
		delay 1
		mount volume Share1
		delay 1
		mount volume Share2
		delay 1
		mount volume Share3
 
		--If all goes well, tell the user that it worked.
		display dialog "You are now connected to the network shared drives." buttons {"OK"}
 
		--If it did not go well, tell the user that there was an error.
	on error e number n
		beep
		--return n
		if n = -55 then
			display dialog "You are already connected to the VPN and your shared drives mounted." buttons {"Ok"}
 
		else if n = -5000 then
			set FirstTryPWD to false
			display dialog "Wrong password, please run the Connection script again." buttons {"Ok"}
		else
			display dialog "Error: " & n & " " & e buttons {"Ok"}
		end if
 
	end try
end tell
--Creating directory and username file in the users Library for Disconnect script use.
do shell script "mkdir -p ~/Library/scripthouse/"
do shell script "echo " & User & " > ~/Library/scripthouse/domain-username"

VPN-SMB-DisconnectScript:

(*
	"VPN & SMB Disconnect Script" by mikesyr at gmail.com
	 v .02 Alpha Released 00/00/05
 
	 Notes: 
 
	 	It has only been tested on Tiger.
 
		This script pulls the username from a file created by the connection script. This is used to properly unmount the users Home directory.
*)
 
--Pull the username
do shell script "cat ~/Library/scripthouse/domain-username"
set User to the result
--Unmount the volumes
tell application "Finder"
	try
		eject "share1"
		eject "share2"
		eject "share3"
		eject "" & User & "$"
	end try
end tell
delay 1
--Disconnect from the VPN
tell application "Internet Connect"
	if seconds connected of status of configuration "VPN (PPTP)" is greater than 0 then
		disconnect configuration "VPN (PPTP)"
	end if
	quit
end tell

Navigation
Personal Tools