{"id":2354,"date":"2014-12-15T16:06:32","date_gmt":"2014-12-15T14:06:32","guid":{"rendered":"http:\/\/9v.lt\/blog\/?p=2354"},"modified":"2022-01-19T08:34:38","modified_gmt":"2022-01-19T06:34:38","slug":"change-outlook-signature-vbs","status":"publish","type":"post","link":"https:\/\/9v.lt\/blog\/change-outlook-signature-vbs\/","title":{"rendered":"Change text in Outlook signature files with VBScript"},"content":{"rendered":"<p>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!<br \/>\nScript can be found here: <a href=\"http:\/\/9v.lt\/projects\/other\/change_signature.vbs\" target=\"_blank\" rel=\"noopener\">http:\/\/9v.lt\/projects\/other\/change_signature.vbs<\/a><br \/>\n<!--more--><br \/>\nHere&#8217;s the script for quick review:<\/p>\n<pre lang=\"vb\" line=\"1\">\r\n'=================================================\r\n'  Description:\r\n'       Changes a string in a HTM file for Outlook signatures.\r\n'=================================================\r\n\r\nSet wshShell = CreateObject(\"WScript.Shell\")\r\nSet objFS = CreateObject(\"Scripting.FileSystemObject\")\r\n\r\nConst sigDir = \"%appdata%\\Microsoft\\Signatures\"\r\nConst sigFTmp = \"_tmp\"\r\nConst oldLink = \"qwerty\"\r\nConst oldLink1 = \"azerty\"\r\nConst newLink = \"asdfg\"\r\n\r\nIf (objFS.FolderExists(wshShell.ExpandEnvironmentStrings(sigDir))) Then\r\n    Dim objFile\r\n    For Each objFile In objFS.GetFolder(wshShell.ExpandEnvironmentStrings(sigDir)).Files\r\n        'only proceed if there is an extension on the file.\r\n        If (InStr(objFile.Name, \".\") > 0) Then\r\n            'If the file's extension is \"htm\", write the path to the output file.\r\n            If (LCase(Mid(objFile.Name, InStrRev(objFile.Name, \".\"))) = \".htm\") Then\r\n                Set textStream = objFS.GetFile(objFile.Path).OpenAsTextStream(1, -2)\r\n                Set objOutFile = objFS.CreateTextFile(objFile.Path & sigFTmp, True)\r\n                REM x = MsgBox(objFile.Path & sigFTmp, 0, \"qqqq\")\r\n                Do Until textStream.AtEndOfStream\r\n                    strLine = textStream.ReadLine\r\n                    If (InStr(strLine, oldLink) > 0) Then\r\n                        strLine = Replace(strLine, oldLink, newLink)\r\n                        REM x = MsgBox(strLine, 0, \"wwwww\")\r\n                    End If\r\n                    If (InStr(strLine, oldLink1) > 0) Then\r\n                        strLine = Replace(strLine, oldLink1, newLink)\r\n                        REM x = MsgBox(strLine, 0, \"eeee\")\r\n                    End If\r\n                    objOutFile.WriteLine(strLine)\r\n                Loop\r\n                objOutFile.Close()\r\n                textStream.Close()\r\n                oldFilename = objFile.Path\r\n                objFS.DeleteFile(oldFilename)\r\n                objFS.MoveFile oldFilename & sigFTmp, oldFilename\r\n            End If\r\n        End If\r\n    Next\r\nEnd If\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Some guy at work decided to change our Facebook group name and effectively remove the<\/p>\n","protected":false},"author":2,"featured_media":2282,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,750],"tags":[436,922,414],"class_list":["post-2354","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-projects","category-software-projects","tag-outlook","tag-signature","tag-vbscript"],"_links":{"self":[{"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/posts\/2354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/comments?post=2354"}],"version-history":[{"count":0,"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/posts\/2354\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/media\/2282"}],"wp:attachment":[{"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/media?parent=2354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/categories?post=2354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/tags?post=2354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}