?
Solved

how to delete outlook signature file with VBS

Posted on 2013-02-04
3
Medium Priority
?
2,460 Views
Last Modified: 2013-02-04
hi all

i need to create a vbs script to delete a outlook signature from the signatures folder.
im fairly new to vbs scripting and im not sure which is the best way to go around this... ive seen plenty of examples of file name contains this and that...
but im totally confused as to what is the best process for me.

the difficulty here is that the file names created contain the username variable
what i mean by that is that the final name is called

ausamj_Signature.htm

every user has one of these, and every file is called AUS***_Signature.htm
this file resides in

C:\Users\ausamj\AppData\Roaming\Microsoft\Signatures


in regards to the scripting side, my understanding is that we need to find out first who is logged on, so i have a script for that.


Dim objNetwork
Dim userName
 
Set objNetwork = CreateObject("WScript.Network")
userName = objNetwork.UserName
 
WScript.Echo userName



and then somehow use the UserName variable to find the .htm file containing ausamj
and then delete it.... am i on the right path?


the reason why we cant delete *.htm is because users create their own signatures, so delete *.htm would remove all of them.
we only want to delete the standard one that is created by us.


so we need to find out who is logged on
locate the correct .htm file for the user, and then delete it.


appreciate if somebody could give me a hand with this


cheers!
0
Comment
Question by:BakerSyd
[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
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
terencino earned 2000 total points
ID: 38853632
Hi BakerSyd, how about this script below. It uses the Shell to extract the user profile of the logged in user, and FileSystemObject to delete the file.

Dim objNetwork, objShell, fso, userName
Set objNetwork = CreateObject("WScript.Network")
Set objShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject") 
userName = objNetwork.UserName
userProfilePath = objShell.ExpandEnvironmentStrings("%UserProfile%")
SignatureFile = UserProfilePath & "\AppData\Roaming\Microsoft\Signatures\" & userName & "_Signature.htm"
fso.DeleteFile SignatureFile

Open in new window

0
 

Author Comment

by:BakerSyd
ID: 38853656
hey

that script is fantastic, does exactly what i want


thanks for your help !
0
 
LVL 16

Expert Comment

by:terencino
ID: 38853661
You're welcome, good luck with the implementation, and thanks for the grade!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…
Suggested Courses

752 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