Hello guys,

I am trying to find a VBscript similar to the following:


' ------ SCRIPT CONFIGURATION ------
strFilePath = "<FilePath>" ' e.g. "d:\scripts\test.txt"
' ------ END CONFIGURATION ---------

set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile(strFilePath)
WScript.Echo "Successfully deleted file"

I would like to Embed this code in a VBScript Custom Action. Now, the file I'd like to delete resides on the desktop of AllUsers. I was hoping to be able to swap out some hard coded paths with variables that Wise uses. Thing is, we have English and French OS's, so ideally, I'd like to delete something along the lines of
%ALLUSERSPROFILES%\Desktop and %ALLUSERSPROFILES%\Bureau. I'm not sure, does Wise use a Variable pointing directly to the desktop? I wasn't able to find it? And, how would one include this variable directly in this snippet of code?

I'll keep looking, but any help you may supply would greatly be appreciated.

Thanks all!

Stephane
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
Why use a script? An MSI can do this for you. Check out MSDN for how to use the RemoveFiles table.
Answered 01/30/2009 by: VBScab
Red Belt

Please log in to comment
0
Hello sir!

You are indeed right. But i was under the impression that to use the RemoveFile table you needed to link your file to a Component first right?

Essentially, I'm trying to remove a shortcut from the All Users Desktop. I can't find the shortcut neither in Shortcuts, Shortcuts Table, Custom Action, no where. Hence why I've come to the resolve that removing it via script would solve the problem.

Since I can't find the shortcut in none of the Component's of my MSI, can I still use the RemoveFile Table even tough the file doesn't seem to be linked no where?
Answered 01/30/2009 by: Fau
Senior Purple Belt

Please log in to comment
0
Stephane, just create a new component called.......oooooooooh, I don't know......RemoveShortcut and link to that.

You use WPS, right?
Answered 01/30/2009 by: VBScab
Red Belt

Please log in to comment
0
What you may need to consider is that the file might be created there with a custom action or external process that takes place after the RemoveFile action. I agree that you should try the RemoveFile table first though.

This is one of my favorite sites on the internet:
http://www.cruto.com/resources/vbscript/vbscript-examples/vbscript-sitemap.asp
Answered 01/30/2009 by: turbokitty
Sixth Degree Black Belt

Please log in to comment
0
Hello guys!

Ok, so here I am, on this problem again. I did as suggested by Ian, to no avail. I think I'm having exactly what TK implied: my shortcut is created after the RemoveFile action. Now, I tried circumventing this by copying the RemoveFile action from my custom action to Remove File 1 and placing it at the end of my custom actions list. However, this was not a success since other actions seem to depend upon this.

Which leaves me back to my initial solution: scripting a code and embedding it in a CA. (By the way, thanks TK, super site, bookmarked for future use!!!!).

So, is there a way i can map myself directly on the desktop in order to get something along the lines of:

strFilePath = %ALLUSERSPROFILES% & "\Desktop" (using Windows Variables) and/or,
strFilePath = [DesktopFolder] (using Wise Variables)
instead of
strFilePath = "C:\Documents and Settings\All Users\Desktop"

?

If at all possible, I'd like to avoid having to test for which language of XP is installed before setting my variable.

Anyway, Thanks for your continued help on the matter!

Stephane
Answered 02/03/2009 by: Fau
Senior Purple Belt

Please log in to comment
0
I think I'm having exactly what TK implied: my shortcut is created after the RemoveFile action. If it's the case that a CA is creating the shortcut, you can avoid all the heartache you're going through simply by preventing that CA from running. The easiest route is to add an impossible-to-meet condition to it. I normally use '0=1' as it's hard to think of a condition which is more impossible to meet! [waits for lengthy argument from mathemeticians...]
Answered 02/03/2009 by: VBScab
Red Belt

Please log in to comment
0
Usually I do something along those lines, but in this case I'm unable to find which custom action creates the shortcut. I've tried browsing the list up and down left and right, nothing. Even a colleague of mine cheked to make sure I wasn't looking with a closed eye. Nada :(
Answered 02/03/2009 by: Fau
Senior Purple Belt

Please log in to comment
0
Have you tried:

- a verbose log
- running the MSI through your authoring tool's debugger?

This last is the best option as you can watch the desktop and as soon as the s/c appears, the CA involved (if, indeed, it's created by a CA) will be highlighted.
Answered 02/03/2009 by: VBScab
Red Belt

Please log in to comment
0
This will help you deleting the file via VBS Script on all users Desktop folder if file exists:
Example

'this script will check the file exists, and then it will delete it.
Option Explicit
On Error Resume next
Const alluser = &H19&
Dim Objshell
Dim oFSO
Dim filetokill
Dim oAlluser
Dim oAlluserItem

Set oFSO = Createobject("scripting.filesystemobject")
Set objShell = CreateObject("Shell.Application")
Set oAlluser = objShell.Namespace(alluser)
Set oAlluserItem = oAlluser.Self

filetokill = oAlluserItem.Path & "\Test.url" 'Just replace this item with your file you want to delete

If oFSO.fileexists (filetokill) Then
oFSO.deletefile (filetokill)
End If
on error goto 0

Cheers
Answered 08/04/2009 by: McRip
Orange Senior Belt

Please log in to comment
0
Hi,
still if your shortcut does not get deleted then, check is it a shortcut or just icon created because of namespace registry?
Answered 08/04/2009 by: abking99
Second Degree Blue Belt

Please log in to comment
0
It doesn't matter what kind of file it is. URL, LNK...
The file you wanna get deleted gets deleted...

Cheers
Answered 08/04/2009 by: McRip
Orange Senior Belt

Please log in to comment
Answer this question or Comment on this question for clarity