|
-
Aug 28th, 2006, 01:53 PM
#1
Thread Starter
Junior Member
force a program to delete itself
Hey guys
I am writing a cleanup program to delete some files etc. of a program I am copying to the desktop. Is there a way I can force the program to delete itself once it is complete? If not can I send it to a temp file? If I can, is there a special path for a temp directory?
Thanks
Mita
-
Aug 28th, 2006, 02:25 PM
#2
Re: force a program to delete itself
A program that is running can not delete itself nor move its location. Maybe it would be better to have it start running from the Temp directory. 
You can use this API to get the Temp directory path.
VB Code:
Private Declare Function GetTempPath Lib "kernel32.dll" Alias "GetTempPathA" (ByVal nBufferLength As Int32, ByVal lpBuffer As String) As Int32
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 28th, 2006, 02:54 PM
#3
Re: force a program to delete itself
or you can make a .bat file that will delete your program after execution
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Aug 28th, 2006, 03:00 PM
#4
Thread Starter
Junior Member
Re: force a program to delete itself
so possibly copy a .bat file to a temp folder and have the end of my program a little something like this:
Process.Start("path")
End
Mita
-
Aug 28th, 2006, 03:26 PM
#5
Re: force a program to delete itself
yes, that's right
VB Code:
System.IO.File.CreateText("Path\File.bat").Write("pause" + ControlChars.NewLine _
+ "@ECHO OFF" + ControlChars.NewLine + "del" + Application.ExecutablePath)
Process.Start("Path")
End
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Aug 28th, 2006, 05:16 PM
#6
Re: force a program to delete itself
But then your left with the same problem, a left over file.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 28th, 2006, 06:10 PM
#7
Re: force a program to delete itself
 Originally Posted by RobDog888
But then your left with the same problem, a left over file.
If you put the batch file in the temp folder there will be no problem, and as I understood he'd use both ideas.
BTW I hope the idea is not for a virus or something harmful, otherwise why would you want your app to be deleted?
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Aug 28th, 2006, 06:28 PM
#8
Frenzied Member
Re: force a program to delete itself
 Originally Posted by ComputerJy
BTW I hope the idea is not for a virus or something harmful, otherwise why would you want your app to be deleted?
Honestly, this is what it sounds like.
I'll Be Back!
T-1000
Microsoft .Net 2005
Microsoft Visual Basic 6
Prefer using API
-
Aug 28th, 2006, 07:12 PM
#9
Re: force a program to delete itself
 Originally Posted by MitaDC
Hey guys
I am writing a cleanup program to delete some files etc. of a program I am copying to the desktop. ...
This appears to be the reason for the self delete but even if its not, the IP and provider and other info is automatically stored with each and every post.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 28th, 2006, 09:50 PM
#10
Hyperactive Member
Re: force a program to delete itself
How does an uninstaller work? Couldn't you just do an unistall?
Visual Studio .NET 2005/.NET Framework 2.0
-
Aug 29th, 2006, 06:45 AM
#11
Re: force a program to delete itself
Even uninstallers leave some temp files on your computer.
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Aug 29th, 2006, 07:31 AM
#12
Re: force a program to delete itself
Thats usually because they dont write them to clean up all files as some are added by the user during the programs use or customization settings. Registry keys, temp files, and program folders etc all can be left behind during an uninstall.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 29th, 2006, 03:38 PM
#13
Thread Starter
Junior Member
Re: force a program to delete itself
I actually work for a company where I want to copy an auto-install program to the desktop but then when I am finished with the install files (PC-Cillin etc.) I want to run a program from a shortcut to delete all of the files that have been copied to the desktop.
Mita
-
Aug 29th, 2006, 03:44 PM
#14
Re: force a program to delete itself
Since your on a LAN its allot easier and better if you use publishing features or GPOs to make sure the app is installed wher ever they log in to on the network. No installation files are needing to be removed since they run from the server.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 29th, 2006, 07:08 PM
#15
Thread Starter
Junior Member
Re: force a program to delete itself
alright will look into.
Thanks
And thanks for assuming I was writing a virus
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|