Some guy at work decided to change our Facebook group name and effectively remove the old Facebook group link. We used that old link for all of our employee email signatures and of course it all got b0rked. Only way to deal with this was to write a quick VBS script and put it into a GPO Logon. It seemed to fix it, day was saved!
Script can be found here: http://9v.lt/projects/other/change_signature.vbs
Here’s the script for quick review:
'=================================================
' Description:
' Changes a string in a HTM file for Outlook signatures.
'=================================================
Set wshShell = CreateObject("WScript.Shell")
Set objFS = CreateObject("Scripting.FileSystemObject")
Const sigDir = "%appdata%\Microsoft\Signatures"
Const sigFTmp = "_tmp"
Const oldLink = "qwerty"
Const oldLink1 = "azerty"
Const newLink = "asdfg"
If (objFS.FolderExists(wshShell.ExpandEnvironmentStrings(sigDir))) Then
Dim objFile
For Each objFile In objFS.GetFolder(wshShell.ExpandEnvironmentStrings(sigDir)).Files
'only proceed if there is an extension on the file.
If (InStr(objFile.Name, ".") > 0) Then
'If the file's extension is "htm", write the path to the output file.
If (LCase(Mid(objFile.Name, InStrRev(objFile.Name, "."))) = ".htm") Then
Set textStream = objFS.GetFile(objFile.Path).OpenAsTextStream(1, -2)
Set objOutFile = objFS.CreateTextFile(objFile.Path & sigFTmp, True)
REM x = MsgBox(objFile.Path & sigFTmp, 0, "qqqq")
Do Until textStream.AtEndOfStream
strLine = textStream.ReadLine
If (InStr(strLine, oldLink) > 0) Then
strLine = Replace(strLine, oldLink, newLink)
REM x = MsgBox(strLine, 0, "wwwww")
End If
If (InStr(strLine, oldLink1) > 0) Then
strLine = Replace(strLine, oldLink1, newLink)
REM x = MsgBox(strLine, 0, "eeee")
End If
objOutFile.WriteLine(strLine)
Loop
objOutFile.Close()
textStream.Close()
oldFilename = objFile.Path
objFS.DeleteFile(oldFilename)
objFS.MoveFile oldFilename & sigFTmp, oldFilename
End If
End If
Next
End If