Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using FileExists 1

Status
Not open for further replies.

swabs

IS-IT--Management
Jul 28, 2003
155
US
Hello,
I am trying to run a reycle bin cleaner if the file "binmanager.dll" exists in %systemroot\system32. The script works well without the If statement and I have verified that the file does exist. But when I run the script it acts as if the file doesn't exist. Is there anything incorrect in using the variable %systemroot% ??

code is below
thanks,
Ben


Dim fso
Dim filesys
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("%systemroot%\system32\binmanager.dll") Then
Set fso = CreateObject("BinManager.RecycleBin")
fso.DeleteOldItems(10)

End if

 
Set WshShell = CreateObject("WScript.Shell")
If filesys.FileExists(WshShell.ExpandEnvironmentStrings("%systemroot%") & "\system32\binmanager.dll") Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PVH,
thanks for the response. I have modified what you posted a bit and it seems to work. Thanks again.

Ben

Dim fso
Dim filesys
systemroot= CreateObject("wscript.shell").expandenvironmentstrings("%systemroot%")

Set filesys = CreateObject("Scripting.FileSystemObject")

If filesys.FileExists(systemroot & "\system32\binmanager.dll") Then
Set fso = CreateObject("BinManager.RecycleBin")
fso.DeleteOldItems(10)

End if

WScript.Echo systemroot & "\system32\binmanager.dll"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top