Make a file visible?
Hello guys I hope you can help me with the following issue...
I'm using Wise Installation Studio 7.3.0.250.
I have file called ".xyz". This file has been saved by a third party application in the CommonAppDataFolder.
It is hidden and has the attrib system.
I want this file get deleted during install and uninstall by my application...
How can I make it visible, make the system attrib vanish and how can I delete it after all that by my msi application?
This must work under win2000 to win7.
Any ideas?
Thanks in advance
Cheers
I'm using Wise Installation Studio 7.3.0.250.
I have file called ".xyz". This file has been saved by a third party application in the CommonAppDataFolder.
It is hidden and has the attrib system.
I want this file get deleted during install and uninstall by my application...
How can I make it visible, make the system attrib vanish and how can I delete it after all that by my msi application?
This must work under win2000 to win7.
Any ideas?
Thanks in advance
Cheers
0 Comments
[ + ] Show comments
Answers (27)
Please log in to answer
Posted by:
emmy12
13 years ago
Posted by:
McRip
13 years ago
Posted by:
suchi.jigar
13 years ago
Posted by:
McRip
13 years ago
Posted by:
suchi.jigar
13 years ago
Posted by:
McRip
13 years ago
Posted by:
suchi.jigar
13 years ago
'this script will check the file exists, and then it will delete it.
Option Explicit
On Error Resume NExt
Dim Objshell
Dim Objfso
Dim strallusersfiles
Dim strpath
Dim strpath1
Dim strpath2
Dim objfolder
Set objshell = Createobject("Wscript.shell")
Set Objfso = Createobject("scripting.filesystemobject")
strallusersfiles = objshell.expandenvironmentstrings("%allusersprofile%")
strpath = strallusersfiles & "\Application Data\Suchikant.txt"
If objfso.fileexists (strpath) Then
objfso.deletefile (strpath)
End If
Option Explicit
On Error Resume NExt
Dim Objshell
Dim Objfso
Dim strallusersfiles
Dim strpath
Dim strpath1
Dim strpath2
Dim objfolder
Set objshell = Createobject("Wscript.shell")
Set Objfso = Createobject("scripting.filesystemobject")
strallusersfiles = objshell.expandenvironmentstrings("%allusersprofile%")
strpath = strallusersfiles & "\Application Data\Suchikant.txt"
If objfso.fileexists (strpath) Then
objfso.deletefile (strpath)
End If
Posted by:
McRip
13 years ago
Posted by:
McRip
13 years ago
Posted by:
suchi.jigar
13 years ago
Posted by:
suchi.jigar
13 years ago
Posted by:
dj_xest
13 years ago
Posted by:
suchi.jigar
13 years ago
Posted by:
McRip
13 years ago
Posted by:
McRip
13 years ago
I was testing a bit more and it is working. The reason why it didn't work before is pretty simple.
I'm testing on a German operating system.
My question now is:
The path variable for english operating systems is %ALLUSERSPROFILE%\Application Data
The path variable for german operating systems is %ALLUSERSPROFILE%\Anwendungsdaten
Is there a global path variable for solving this issue? Because it can not be true that it doesn't work on different operating systems with different languages.
There must be a resolution for it.
Any ideas???????????? Because I want to get it working. Please understand this, guys.
Thanks in advance
I'm testing on a German operating system.
My question now is:
The path variable for english operating systems is %ALLUSERSPROFILE%\Application Data
The path variable for german operating systems is %ALLUSERSPROFILE%\Anwendungsdaten
Is there a global path variable for solving this issue? Because it can not be true that it doesn't work on different operating systems with different languages.
There must be a resolution for it.
Any ideas???????????? Because I want to get it working. Please understand this, guys.
Thanks in advance
Posted by:
anonymous_9363
13 years ago
Use the CommonAppDataFolder property instead of an environment variable. http://msdn.microsoft.com/en-us/library/aa367992%28VS.85%29.aspx
Posted by:
McRip
13 years ago
ORIGINAL: VBScab
Use the CommonAppDataFolder property instead of an environment variable. http://msdn.microsoft.com/en-us/library/aa367992%28VS.85%29.aspx
I knew that this point will be posted...
Thanks VBScab.
Do I have to use it in brackets or not in the embedded vb code?
[CommonAppDataFolder] or CommonAppDataFolder
Thanks in advance
Posted by:
anonymous_9363
13 years ago
All properties need to be referenced inside square brackets, yes.
How one accesses properties in embedded VBS depends on where the CA is sequenced.
In 'Execute Immediate', use Session.Property("the_name_of_the_property"). In 'Execute Deferred', scripts have access to only a very limited set of properties, one of which is 'CustomActionData'. Use of that special property is tricky to explain but I have a go here http://itninja.com/question/how-do-you-roll-out-new-machines?7008&mpage=1&key=customactiondata榃 and our good friend Owen posts a link to another explanation below my post.
How one accesses properties in embedded VBS depends on where the CA is sequenced.
In 'Execute Immediate', use Session.Property("the_name_of_the_property"). In 'Execute Deferred', scripts have access to only a very limited set of properties, one of which is 'CustomActionData'. Use of that special property is tricky to explain but I have a go here http://itninja.com/question/how-do-you-roll-out-new-machines?7008&mpage=1&key=customactiondata榃 and our good friend Owen posts a link to another explanation below my post.
Posted by:
McRip
13 years ago
OK, guys, if you are interested, here is my modified code and it works great:
'this script will check the file exists, and then it will delete it.
Option Explicit
On Error Resume next
Const alluser = &H23&
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 & "\something.txt"
If oFSO.fileexists (filetokill) Then
oFSO.deletefile (filetokill)
End If
on error goto 0
Cheers
'this script will check the file exists, and then it will delete it.
Option Explicit
On Error Resume next
Const alluser = &H23&
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 & "\something.txt"
If oFSO.fileexists (filetokill) Then
oFSO.deletefile (filetokill)
End If
on error goto 0
Cheers
Posted by:
anonymous_9363
13 years ago
Your script (not uncommonly) assumes that everything is going to work. A basic addition would be:
If oFSO.fileexists (filetokill) Then
oFSO.deletefile (filetokill)
If oFSO.fileexists (filetokill) Then
'// Tell the user by your chosen mechanism (e.g. MsgBox or Event Log, preferably both) that the delete failed
End If
End If
on error goto 0
Posted by:
McRip
13 years ago
Posted by:
McRip
13 years ago
Posted by:
anonymous_9363
13 years ago
The script is a bad example on its use, since it's used here to stop any errors interrupting the program's flow but without any handling of any error which might occur. Thus, if for some reason the Shell object failed to be created, the script would carry on regardless. Of course, it's unlikely that that would happen but, as I'm forever trying to tell people, you should ALWAYS assume that the worst WILL happen. So, taking the Shell object creation as an example, it really ought to look like this:
Set objshell = Createobject("Wscript.shell")
If Not IsObject(objshell) Then
'// Tell the user that their machine is seriously broken
WScript.Quit(False)
End If
...and so on.When you've written a few scripts which include object creation, you'll quickly add a function template called, say, ObjectCreation, to which you can add all the error-handling, meaning that the code which does the work isn't cluttered with endless 'If Not IsObject' constructs.

so that the conversation will remain readable.