Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Outlook Signature Script Error

Posted on 2013-05-17
5
Medium Priority
?
619 Views
Last Modified: 2013-05-28
We have a outlook signature script that runs every time a user logs on a computer. The script runs flawlessly unless it is their first time logging on the computer. If it is their first time the script gives an error (attached). Is there a way of creating the signature directory without running outlook? It looks like the script will fail unless the user has a outlook profile on the computer. This particuarly happens in meeting rooms where the user doesn't normally login. I also attached the script for reference.

Thanks!
OutlookSig1-Example.vbs
Script-Error.PNG
0
Comment
Question by:ICCNetworkAdmin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 6

Expert Comment

by:Alan Gunn
ID: 39175139
What a cool script!

Unfortunatley, as you surmise, the registry won't contain the required keys until the user logs on and starts Outlook.

If you have a domain and central storage of some kind you could set up roaming profiles.

In this scenario, the "User" registry keys and potentially other specific folders are stored centrally and are applied to each machine that the user logs into.

Could be worth a look. :-)

Cheers!

TRM
0
 
LVL 83

Accepted Solution

by:
David Johnson, CD, MVP earned 1000 total points
ID: 39175357
Here is the modified script
 Set objUser = CreateObject("WScript.Network")
userName = objUser.UserName
domainName = objUser.UserDomain 

FUNCTION GetUserDN(BYVAL UN, BYVAL DN)
Set ObjTrans = CreateObject("NameTranslate")
objTrans.init 1, DN
objTrans.set 3, DN & "\" & UN
strUserDN = objTrans.Get(1)
GetUserDN = strUserDN
END FUNCTION

Set objLDAPUser = GetObject("LDAP://" & GetUserDN(userName,domainName))

Dim objFSO, objWsh, appDataPath, pathToCopyTo, plainTextFile, plainTextFilePath, richTextFile, richTextFilePath, htmlFile, htmlFilePath
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWsh = CreateObject("WScript.Shell")
appDataPath = objWsh.ExpandEnvironmentStrings("%APPDATA%")
'
' added section
'
pathToCopyTo = appDataPath & "\Microsoft\Signatures\"
If Not objFSO.FolderExists(pathToCopyTo) Then
   objFSO.CreateFolder(pathToCopyTo)
End If
'
' end of modified Section
'
plainTextFilePath = pathToCopyTo & "Default.txt"
Set plainTextFile = objFSO.CreateTextFile(plainTextFilePath, TRUE)
plainTextFile.WriteLine(objLDAPUser.FirstName & " " & objLDAPUser.LastName)
plainTextFile.WriteLine(objLDAPUser.title)
plainTextFile.WriteLine ("Insert Company Here")
plainTextFile.WriteLine [BR]
If Len(objLDAPUser.physicalDeliveryOfficeName) > 1 THEN
	IF  CStr(REPLACE(objLDAPUser.physicalDeliveryOfficeName, "x", "")) >  200 THEN
		plainTextFile.WriteLine("Insert Phone Here" & REPLACE(objLDAPUser.physicalDeliveryOfficeName, "x", "" ) & " (Direct) ")
	ELSE
		plainTextFile.WriteLine("Insert Phone Here" & REPLACE(objLDAPUser.physicalDeliveryOfficeName, "x", "") & " (Direct) ")
	END If
END If
IF  Len(objLDAPUser.telephoneNumber) > 3 THEN
  plainTextFile.WriteLine(objLDAPUser.telephoneNumber & " " & "(Cell)")
END If
 
plainTextFile.WriteLine( "(xxx) xxx-xxxx (Fax) " )
plainTextFile.Close

Open in new window

0
 

Author Comment

by:ICCNetworkAdmin
ID: 39176682
Unfortunatly the modified script did not put any signatures in outlook when the profile was created.
0
 
LVL 76

Assisted Solution

by:David Lee
David Lee earned 1000 total points
ID: 39201105
Is it the absence of a Signature folder that's causing the error?  If so, then yes, you can create the folder outside of Outlook.  Add this code to the script you already have and insert a call to it immediately after this line

Set objWsh = CreateObject("WScript.Shell")

Sub CreateSigFolder()
    Dim objFSO, objShl, strFld
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objShl = CreateObject("WScript.Shell")
    strFld = objShl.ExpandEnvironmentStrings("%AppData%") & "\Microsoft\Signatures"
    If Not objFSO.FolderExists(strFld) Then objFSO.CreateFolder (strFld)
    Set objFSO = Nothing
    Set objFld = Nothing
End Sub

Open in new window

0
 

Author Closing Comment

by:ICCNetworkAdmin
ID: 39201945
Thank you for the help! With the help of ve3ofa and BlueDevilFan the script is now working as needed. We backed away from the Default part because some users were complaining but as for the error it no longer appears.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question