Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » Batch help, delete file after process closes
Closed Thread
Old 06-30-2008, 10:17 PM   #1 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,686

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Batch help, delete file after process closes

I need help making a batch file. I want it to open a game, then after the game closes I want it to delete a file from the game.

The game is Call of Duty 4, and the file is called zzz-unitedsniper.iwd I think. This file is not supposed to be there but some servers still have it, so it downloads, then messes up.

I am sick of manually deleting it, and want a batch file to automatically delete it when I close the game.

Is this possible? I've tried Google'ing to no avail.

Thanks.
__________________

Need website help? PM me!
CrazeD is offline  
Old 06-30-2008, 11:10 PM   #2 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default Re: Batch help, delete file after process closes

This isn't possible with a batch file. You need something that can do event driven programming.

You could do this with a vbscript, but it would have to loop infinitely checking every x seconds if the process for the game still existed.
__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
Old 06-30-2008, 11:24 PM   #3 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default Re: Batch help, delete file after process closes

Here's a sample of this

Code:
'Enter Game Process name here
strName = "process.exe"

'Enter Entire path to file to be delete here
strFile = "c:\program files\game\file.ini"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objFso = CreateObject("Scripting.FileSystemObject")
   
Do

  Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where name='" & strName & "'")

  blnProcess = 0

  For Each objProcess in colProcessList
    If objProcess.Name = strName Then
      blnProcess = 1
    End If
  Next

  If blnProcess Then
    Exit Do
  End If

Loop

objFso.deletefile(strFile)

__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
Old 07-01-2008, 12:14 AM   #4 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,686

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Re: Batch help, delete file after process closes

Ah.

I guess I'll just make a batch to delete it, without having to browse there.

Thanks.
__________________

Need website help? PM me!
CrazeD is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
A sneaky, and annoying virus donaldj HijackThis Logs (finished) 25 06-16-2008 08:58 PM
WTF is a Bad Block? MikesCreation Hardware Troubleshooting 18 02-24-2008 09:31 PM
Another Hijack Log boo HijackThis Logs (finished) 17 06-26-2007 12:30 PM