MSFN Forum: Delete specific file on shutdown? - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Delete specific file on shutdown? Rate Topic: -----

#1 User is offline   JonesDK 

  • Group: Members
  • Posts: 8
  • Joined: 26-March 05

  Posted 27 September 2005 - 08:25 PM

Hi... I'm curious to find out how to make Windows delete a specific file on shutdown...

I'd rather do it on shutdown instead of startup. It's just a simple playlist but anyway... if you got a tip for me, please let me know.

BTW, I'm using Windows XP Pro.

Thanx :)


#2 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,364
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 28 September 2005 - 01:32 AM

Click
    Start » Run » (type) gpedit.msc » OK
Then
    Computer Configuration » Windows Settings » Scripts (Startup/Shutdown) » (Double Click) Shutdown » Add
and browse to your script etc.

#3 User is offline   JonesDK 

  • Group: Members
  • Posts: 8
  • Joined: 26-March 05

Posted 28 September 2005 - 03:10 AM

Ahh... nice :)

Thank You!

#4 User is offline   atomizer 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 578
  • Joined: 24-December 04
  • OS:none specified
  • Country: Country Flag

Posted 28 September 2005 - 03:45 AM

if you're trying to delete files that are in use by windows, you can use unlocker. works like a champ.

#5 User is offline   JonesDK 

  • Group: Members
  • Posts: 8
  • Joined: 26-March 05

Posted 02 October 2005 - 05:08 AM

It's nothing like that but thanx anyway. It has to be done on every shutdown. Trying to figure out this scripting thing. So far I've figured I should use this:

function DeleteFile(filespec)
{
   var fso;
   fso = new ActiveXObject("Scripting.FileSystemObject");
   fso.DeleteFile(filespec);
}


Just seems to be put into content in some way. Can't use the function as it is...

The file is:

C:\Program Files\foobar2000\playlists\000000000 - Default.fpl


- or maybe the entire folder.

Any help would be appreciated :)

This post has been edited by JonesDK: 02 October 2005 - 05:09 AM


#6 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,364
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 02 October 2005 - 06:49 AM

In vbs you will probably want something like this
WScript.CreateObject("Scripting.FileSystemObject").DeleteFile("C:\Program Files\foobar2000\playlists\000000000 - Default.fpl")


#7 User is offline   JonesDK 

  • Group: Members
  • Posts: 8
  • Joined: 26-March 05

Posted 02 October 2005 - 07:58 AM

Awesome - it works :D

Thank You Yzöwl!

#8 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,352
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 02 October 2005 - 11:36 AM

This is with a error control in it. It is always better to use a If Exists Statement,
in a vbs script.
If Exists statement to delete file

Quote


Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
If Fso.FileExists("C:\Program Files\foobar2000\playlists\000000000 - Default.fpl") Then
Fso.DeleteFile("C:\Program Files\foobar2000\playlists\000000000 - Default.fpl")
Else
Msgbox "Cannot Find File", 0 + 32, "Error"
End If
If Not Statement to delete file

Quote


Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
If Not Fso.FileExists("C:\Program Files\foobar2000\playlists\000000000 - Default.fpl") Then
Msgbox "Cannot Find File", 0 + 32, "Error"
Else
Fso.DeleteFile("C:\Program Files\foobar2000\playlists\000000000 - Default.fpl")
End If


The If exixts Statement in One Line

Quote

Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject") : If Fso.FileExists("C:\Program Files\foobar2000\playlists\000000000 - Default.fpl") Then Fso.DeleteFile("C:\Program Files\foobar2000\playlists\000000000 - Default.fpl") Else Msgbox "Cannot Find File", 0 + 32, "Error" End If

This post has been edited by gunsmokingman: 02 October 2005 - 11:41 AM


#9 User is offline   JonesDK 

  • Group: Members
  • Posts: 8
  • Joined: 26-March 05

Posted 02 October 2005 - 09:27 PM

Cool... will try one of those. I was a little too quick with the first script. It DID give an error... just not when I tested it using cscript.exe, but on shutdown it did.

This post has been edited by JonesDK: 02 October 2005 - 09:28 PM


#10 User is offline   JonesDK 

  • Group: Members
  • Posts: 8
  • Joined: 26-March 05

Posted 03 October 2005 - 08:59 AM

I get the error "Cannot find script engine 'VBSCript' for 'C:\Script.vbs'"

Any idea how to fix this?

Thanx

#11 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,352
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 03 October 2005 - 12:23 PM

right click the vbs file
select open with
navigate to windows\system32\wscript.exe
select that.
It sound like you have to re associate the wscript as
the defualt script engine.

#12 User is offline   JonesDK 

  • Group: Members
  • Posts: 8
  • Joined: 26-March 05

Posted 04 October 2005 - 12:34 AM

Found another quite simple solution ;)

And by the way, it WAS already associated to wscript, so I don't know exactly what's wrong. Maybe I need a re-install of windows. Been a long time now.

The simple solution was to just make a clean playlist and make it read-only. And it seems to work :D

Thanx all for your suport anyway.

This post has been edited by JonesDK: 04 October 2005 - 12:35 AM


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy