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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What WMI services, etc, do I use to delete a temporarily created file

Status
Not open for further replies.

JustScriptIt

Technical User
Oct 28, 2011
73
US
I am trying to create a script that deletes a file that is generated in the process of a service is shutting down. Once the service has shut down, the file disappears.

That means, the script must
1. Detect the presence of a file
2. Then it can delete it

What WMI tools do I use? Are there other functions I can use to make this work?

Below is pseudo-code
Code:
shutdown smc.exe
while smc.exe is shutting down, detect whether LUInfo.dat has been created. If yes, then delete it.

start smc.exe
 
You can use the FileSystem Object, in particular the FileExists and DeleteFile methods.

Code:
dim fso, sFilename
sFilename = "C:\MyFile.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(sFilename) Then
   fso.DeleteFile sFilename
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top