[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

how to delete outlook signature file with VBS

Posted on 2013-02-04
3
Medium Priority
?
2,512 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
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…
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.

656 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