|
Case study: Consultancy company logon script
Case Studies are provided to FastTrack Software by customers and are provided as-is.
All case studies are unedited except from in most cases having actual company name, domain names, account names
and server names replaced by fictitious names from a fictitious company named Acme.
Please use our Contact Form, if you are interested in submitting
an anonymous case study.
In this case study, a consultancy company has created a logon script to perform the following at logon:
- Connect printers based on groups
- Log all logons to a SQL Server database
- Set up an ODBC driver for an SQL Server application
- Create a corporate Microsoft Outlook signature
- Install common applications
|
Related pages
|
Goes through the basics of the language.
|
|
Browse online documentation.
|
|
How to set up logon scripts with FastTrack Logon.
|
|
|
Script 1: Main logon script
The main logon script basically logs logons to SQL Server, connects printers based on groups and sets
up a SQL Server ODBC connection for the Swyx application. At the bottom of the script, two additional
scripts are included that will create a corporate Microsoft Outlook signature and install the base applications
that all consultants must have.
/* SHOW
WELCOME SPLASH SCREEN */
Splash Welcome to the Acme network,[UserFullName][Return][Return]You are logging on to: [ComputerName],Images/MyCompanyLogo.png
/** LOG LOGON
TO SQL SERVER **/
ExecSQL "Insert
Into LogInData (LoginTime,UserName,ComputerName,ClientName,ClientIP) Values ('[SQLDateTime]','[UserName]',_
'[ComputerName]','[TSClientName]','[TSClientIP]')",192.112.88.12,ServerLoginLog,LoggingUser,bKFG5ghe9FeNST2E2Gv7PQ==
/** SET CLIENT
TIME **/
SetTimeFromServer
/** CONNECT
PRINTERS AND SHARE **/
If UserIsMemberOf Employees Then
ConnectShare M:,\\AcmeSrv24\dfs,Acme
If UserIsMemberOf tek_sec_level_print
Then
ConnectPrinter \\AcmeSrv23\recpsha4alm
ConnectPrinter \\AcmeSrv23\recpa4alm
ConnectPrinter \\AcmeSrv23\tekshaalm
ConnectPrinter \\AcmeSrv23\recpa4kraft
SetPrinterDefault \\AcmeSrv23\recpsha4alm
End If
If UserIsMemberOf adm_print Then
ConnectPrinter \\AcmeSrv23\recpsha4alm
ConnectPrinter \\AcmeSrv23\recpa4alm
ConnectPrinter \\AcmeSrv23\recpa4kraft
ConnectPrinter \\AcmeSrv23\erpa4alm
ConnectPrinter \\Acme.dk\hjogls13
SetPrinterDefault \\AcmeSrv23\recpsha4alm
End If
If UserIsMemberOf erp_print Then
ConnectPrinter \\AcmeSrv23\recpa4alm
ConnectPrinter \\AcmeSrv23\recpa4kraft
ConnectPrinter \\AcmeSrv23\erpa4alm
ConnectPrinter \\AcmeSrv23\uda4alm
SetPrinterDefault \\AcmeSrv23\erpa4alm
End If
If UserIsMemberOf dev_print Then
ConnectPrinter \\AcmeSrv23\recpa4alm
ConnectPrinter \\AcmeSrv23\recpa4kraft
ConnectPrinter \\AcmeSrv23\erpa4alm
ConnectPrinter \\AcmeSrv23\uda4alm
SetPrinterDefault \\AcmeSrv23\uda4alm
End If
If UserIsMemberOf sales_print Then
ConnectPrinter \\AcmeSrv23\recpsha4alm
ConnectPrinter \\AcmeSrv23\recpa4alm
ConnectPrinter \\AcmeSrv23\recpa4kraft
ConnectPrinter \\AcmeSrv23\erpa4alm
SetPrinterDefault \\AcmeSrv23\recpsha4alm
End If
/* SET UP ODBC
DRIVER FOR SWYX */
WriteRegistry HKLM\SOFTWARE\ODBC\ODBC.INI\swyxcalllist\Driver,
C:\Windows\system32\SQLSRV32.dll
WriteRegistry HKLM\SOFTWARE\ODBC\ODBC.INI\swyxcalllist\Server,
AcmeSrv74\sqlexpress
WriteRegistry HKLM\SOFTWARE\ODBC\ODBC.INI\swyxcalllist\Database,
calldetails
WriteRegistry HKLM\SOFTWARE\ODBC\ODBC.INI\swyxcalllist\LastUser,
xxx
WriteRegistry HKLM\SOFTWARE\ODBC\ODBC.INI\swyxcalllist\Trusted_Connection,
Yes
/* CREATE
OUTLOOK SIGNATURE FILE ONCE */
If UserOnce OutlookSignature
Then
Include CreateSignature.fsh
/* WAIT A
COUPLE OF SECONDS TO AVOID A TOO QUICK SPLASH SCREEN REMOVAL */
Sleep 3
/* INSTALL
APPS - UNLESS IT'S TERMINAL SERVER */
RemoveSplash
If Not RemoteSession
Then Include InstallApps.fsh
Script 2: Outlook signature script file
The main logon script included a script file called CreateSignature.fsh, unless the user
logs on to a non-Remote Desktop Services session. This script
file is included once per user and creates a .txt version and a .htm version of the
signature for any version of Microsoft Outlook. The purpose of automatically creating
the signature file is to ensure that all employees have the same corporate signature.
/** SET
REGISTRY KEYS **/
WriteRegistry HKCU\Software\Microsoft\Office\11.0\Common\General\Signatures,
Signatures
WriteRegistry HKCU\Software\Microsoft\Office\12.0\Common\General\Signatures,
Signatures
WriteRegistry HKCU\Software\Microsoft\Office\14.0\Common\General\Signatures,
Signatures
DeleteRegistryKey HKCU\Software\Microsoft\Office\11.0\Common\MailSettings\NewSignature
DeleteRegistryKey HKCU\Software\Microsoft\Office\11.0\Common\MailSettings\ReplySignature
DeleteRegistryKey HKCU\Software\Microsoft\Office\11.0\Outlook\Options\Mail\EnableLogging
DeleteRegistryKey HKCU\Software\Microsoft\Office\12.0\Common\MailSettings\NewSignature
DeleteRegistryKey HKCU\Software\Microsoft\Office\12.0\Common\MailSettings\ReplySignature
DeleteRegistryKey HKCU\Software\Microsoft\Office\12.0\Outlook\Options\Mail\EnableLogging
/** CREATE
SIGNATURE DIRECTORY **/
If Not DirectoryExists
[UserProfileDir]\Application
Data\Microsoft\Signatures Then
MakeDir [UserProfileDir]\Application
Data\Microsoft\Signatures
End If
/** CREATE TXT
VERSION **/
If FileExists [UserProfileDir]\Application
Data\Microsoft\Signatures\Acme.txt Then
DeleteFile [UserProfileDir]\Application
Data\Microsoft\Signatures\Acme.txt
End If
AppendFile [UserProfileDir]\Application
Data\Microsoft\Signatures\Acme.txt,
AppendFile [UserProfileDir]\Application
Data\Microsoft\Signatures\Acme.txt,Regards
AppendFile [UserProfileDir]\Application
Data\Microsoft\Signatures\Acme.txt,
AppendFile [UserProfileDir]\Application
Data\Microsoft\Signatures\Acme.txt,[UserFullName]
AppendFile [UserProfileDir]\Application
Data\Microsoft\Signatures\Acme.txt,Direct 11223344
AppendFile [UserProfileDir]\Application
Data\Microsoft\Signatures\Acme.txt,
AppendFile [UserProfileDir]\Application
Data\Microsoft\Signatures\Acme.txt,
AppendFile [UserProfileDir]\Application
Data\Microsoft\Signatures\Acme.txt,Acme Road 1 · 91101 Pasadena
AppendFile [UserProfileDir]\Application
Data\Microsoft\Signatures\Acme.txt,Phone 1-555-555-5555
AppendFile [UserProfileDir]\Application
Data\Microsoft\Signatures\Acme.txt,info@Acme.com · www.Acme.com
/** CREATE
HTML VERSION **/
If FileExists [UserProfileDir]\Application
Data\Microsoft\Signatures\Acme.htm Then
DeleteFile [UserProfileDir]\Application
Data\Microsoft\Signatures\Acme.htm
End If
Set HtmlFile=[UserProfileDir]\Application
Data\Microsoft\Signatures\Acme.htm
AppendFile [Var HtmlFile],<html>
AppendFile [Var HtmlFile],<body>
AppendFile [Var HtmlFile],<table
border="0" width="100%"
cellpadding="0" style="border-collapse: collapse">
AppendFile [Var HtmlFile],<tr>
AppendFile [Var HtmlFile],<td
width="50%"><br/>
AppendFile [Var HtmlFile],<font
face="Calibri" style="font-size: 11pt"><font
color="#1F497D">
AppendFile [Var HtmlFile],Regards<br/>
AppendFile [Var HtmlFile],<br/>
AppendFile [Var HtmlFile],<b>[UserFullName]</b><br/>
AppendFile [Var HtmlFile],Direct <a
href="callto: 11223344"><font color="#1F497D">11223344</a><br/>
AppendFile [Var HtmlFile],<br/>
AppendFile [Var HtmlFile],<img border="0" src="Acme-logo.jpg"><br/>
AppendFile [Var HtmlFile],Acme Road 1 ·
91101 Pasadena<br/>
AppendFile [Var HtmlFile],Phone
1-555-555-5555<br/>
AppendFile [Var HtmlFile],</font><a
href="mailto:info@Acme.com"><font color="#1F497D">
AppendFile [Var HtmlFile],info@Acme.com</font></a><font
color="#1F497D"> · </font>
AppendFile [Var HtmlFile],<a
target="_blank" href="http://www.Acme.com"><font
color="#1F497D">
AppendFile [Var HtmlFile],www.Acme.com</font></a></font></td>
AppendFile [Var HtmlFile],<td
width="50%" align="right">
AppendFile [Var HtmlFile],<img
border="0" src="banner.jpg"><br/>
AppendFile [Var HtmlFile],</td>
AppendFile [Var HtmlFile],</tr>
AppendFile [Var HtmlFile],</table>
AppendFile [Var HtmlFile],<i><font
face="Calibri" size="1"><br/>
AppendFile [Var HtmlFile],"This
email may contain personal or confidential information.<br/>"
AppendFile [Var HtmlFile],"If you
are receiving this email by mistake, please return to sender as quickly as
possible"
AppendFile [Var HtmlFile],"without
further distribution, copying or archiving.</font></i>"
AppendFile [Var HtmlFile],</body>
AppendFile [Var HtmlFile],</html>
/** COPY LOGO
AND BANNER FILES **/
If FileExists [UserProfileDir]\Application
Data\Microsoft\Signatures\banner.jpg Then
DeleteFile [UserProfileDir]\Application
Data\Microsoft\Signatures\banner.jpg
End If
If FileExists [UserProfileDir]\Application
Data\Microsoft\Signatures\Acme-logo.jpg Then
DeleteFile [UserProfileDir]\Application
Data\Microsoft\Signatures\Acme-logo.jpg
End If
CopyFile \\Acme.com\netlogon\Acme\banner.jpg,
[UserProfileDir]\Application
Data\Microsoft\Signatures\banner.jpg
CopyFile \\Acme.com\netlogon\Acme\Acme-logo.jpg,
[UserProfileDir]\Application
Data\Microsoft\Signatures\Acme-logo.jpg
Script 3: Install applications script file
The main script included a script named InstallApps.fsh. This script will at all
logons test, if a series of applications is installed and if not, install them in turn
as a domain admin user named "Acmepcinstall". Observe that this approach works only
because UAC is disabled for administrators in this setup. Please refer to the
UAC page for more information. The installations
are not run with unattended switches, because it is allowed to customize installation
options.
/************************
.NET 4 ************************/
If Not ProgramInstalled
Microsoft
.NET Framework 4 Extended Then
LogonUser Acme\Acmepcinstall,cdONm4vA9I51t24ciWfnvw==
MakeDir [TempDir]\TempInstalldotnet
CopyDir \\Acme.com\dfs\Install\_AcmePcInstall\dotnet4,[TempDir]\TempInstalldotnet
SetCurrentDir [TempDir]\TempInstalldotnet
Run dotNetFx40.exe
Splash Microsoft DotNet 4,is now installed on your pc
Sleep 3
RemoveSplash
End If
/************************
OFFICE 2010 ************************/
If Not ProgramInstalled
Microsoft
Office Professionel Plus 2010 Then
LogonUser Acme\Acmepcinstall,cdONm4vA9I51t24ciWfnvw==
MakeDir [TempDir]\TempInstalloffice
CopyDir \\Acme.com\dfs\Install\_AcmePcInstall\Office\Office_Pro_Plus_2010DK,[TempDir]\TempInstalloffice
SetCurrentDir [TempDir]\TempInstalloffice
Run Setup.exe
Splash Office 2010,is now installed on your pc
Sleep 3
RemoveSplash
End If
/************************
SWYX ************************/
If Not ProgramInstalled
SwyxIt!
Then
LogonUser Acme\Acmepcinstall,cdONm4vA9I51t24ciWfnvw==
MakeDir [TempDir]\TempInstallswyx
CopyDir \\Acme.com\dfs\Install\_AcmePcInstall\swyx,[TempDir]\TempInstallswyx
SetCurrentDir [TempDir]\TempInstallswyx
Run MSIexec.exe,/I MSWSE30.msi /QB /NoRestart
If Windows32Bit Then
Run MSIexec.exe,/I SwyxIt!EnglishUK32.msi
/QB /NoRestart
End If
If Windows64Bit Then
Run MSIexec.exe,/I SwyxIt!EnglishUK64.msi
/QB /NoRestart
End If
Splash Swyx,is now installed on your pc
Sleep 3
RemoveSplash
End If
/************************
ADOBE FLASH ************************/
If Not ProgramInstalled
Adobe
Flash Player 11 ActiveX Then
LogonUser Acme\Acmepcinstall,cdONm4vA9I51t24ciWfnvw==
MakeDir [TempDir]\TempInstalladobe
CopyDir \\Acme.com\dfs\Install\_AcmePcInstall\adobe,[TempDir]\TempInstalladobe
SetCurrentDir [TempDir]\TempInstalladobe
If Windows32Bit Then
Run MSIexec.exe,/I flash_player1132bit.msi
/QB /NoRestart
End If
If Windows64Bit Then
Run MSIexec.exe,/I flash_player1164bit.msi /QB
/NoRestart
End If
Splash Adobe Flash Player,is now installed on
your pc
Sleep 3
RemoveSplash
End If
/************************
ADOBE READER ************************/
If Not ProgramInstalled
Adobe
Reader Then
LogonUser Acme\Acmepcinstall,cdONm4vA9I51t24ciWfnvw==
MakeDir [TempDir]\TempInstallreader
CopyDir \\Acme.com\dfs\Install\_AcmePcInstall\adobe,[TempDir]\TempInstallreader
SetCurrentDir [TempDir]\TempInstallreader
Run AdbeRdr1010DK.exe
Splash Adobe Reader X,is now installed on your pc
Sleep 3
RemoveSplash
End If
/************************
TEAM VIEWER ************************/
If Not ProgramInstalled
teamviewer
Then
LogonUser Acme\Acmepcinstall,cdONm4vA9I51t24ciWfnvw==
MakeDir [TempDir]\TempInstallteam
CopyDir \\Acme.com\dfs\Install\_AcmePcInstall\teamviewer,[TempDir]\TempInstallteam
SetCurrentDir [TempDir]\TempInstallteam
Run teamviewer.exe
Splash Teamviewer,is now installed on your pc
Sleep 3
RemoveSplash
End If
/************************
GOTOMAXX ************************/
If Not ProgramInstalled
gotomaxx
Then
LogonUser Acme\Acmepcinstall,cdONm4vA9I51t24ciWfnvw==
MakeDir [TempDir]\TempInstallgoto
CopyDir \\Acme.com\dfs\Install\_AcmePcInstall\gotomaxx,[TempDir]\TempInstallgoto
SetCurrentDir [TempDir]\TempInstallgoto
Run pdfmailer5.exe
Splash GotoMaxx,is now installed on your pc
Sleep 3
RemoveSplash
End If
/************************
DYNAMICS AX ************************/
If Not ProgramInstalled
Microsoft
Dynamics AX 2009 Then
LogonUser Acme\Acmepcinstall,cdONm4vA9I51t24ciWfnvw==
MakeDir [TempDir]\TempInstallax
CopyDir \\Acme.com\dfs\Install\_AcmePcInstall\axapta,[TempDir]\TempInstallax
SetCurrentDir [TempDir]\TempInstallax
Run Setup.exe '',
"HideUI=1 AcceptLicenseTerms=1 LicenseTermsVersion=en-US InstallClientUI=1
ClientConfig=0 ClientAosServer=md02aos"
SetCurrentDir [TempDir]\TempInstallax\sp1
Run axupdate.exe
SetCurrentDir [TempDir]\TempInstallax\HF7SP1
Run axupdate.exe
Splash Dynamics Ax,is now installed on your pc
Sleep 3
RemoveSplash
End If
/************************
JAVA ************************/
If Not ProgramInstalled
Java
Then
LogonUser Acme\Acmepcinstall,cdONm4vA9I51t24ciWfnvw==
MakeDir [TempDir]\TempInstalljava
CopyDir \\Acme.com\dfs\Install\_AcmePcInstall\java,[TempDir]\TempInstalljava
SetCurrentDir [TempDir]\TempInstalljava
Run jre-6u29.exe
Splash Java,is now installed on your pc
Sleep 3
RemoveSplash
End If
/************************
ARCIT ************************/
If Not ProgramInstalled
ArcIT
Then
LogonUser Acme\Acmepcinstall,cdONm4vA9I51t24ciWfnvw==
MakeDir [TempDir]\TempInstallarc
CopyDir \\Acme.com\dfs\Install\_AcmePcInstall\arcit,[TempDir]\TempInstallarc
SetCurrentDir [TempDir]\TempInstallarc
Run setup.exe
Splash ArcIt,is now installed on your pc
Sleep 3
RemoveSplash
End If
/************************
DELETE TEMP FILES ************************/
ResumeOnError
DeleteDir [TempDir]\TempInstallswyx
DeleteDir [TempDir]\TempInstallarc
DeleteDir [TempDir]\TempInstalljava
DeleteDir [TempDir]\TempInstallax
DeleteDir [TempDir]\TempInstallgoto
DeleteDir [TempDir]\TempInstallteam
DeleteDir [TempDir]\TempInstallreader
DeleteDir [TempDir]\TempInstalladobe
DeleteDir [TempDir]\TempInstalloffice
DeleteDir [TempDir]\TempInstalldotnet
StopOnError