| View previous topic :: View next topic |
| Author |
Message |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Tue Jun 15, 2004 2:34 am Post subject: Shell32.dll delete file or something.... |
|
|
Does anyone know if there's a way to delete a file via command line such
as "shell.dll /delete c:\windows\temp\uninstall.exe"
What I want to do is add this command line to the runonce registry so it
can delete my uninstall file the next boot after the user uninstalls my
program.
Any info or help is greatly appreciated, Thanks, _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Tue Jun 15, 2004 3:37 am Post subject: |
|
|
Easiest way is to use a batch file.
or
Under Windows 9x you can use/create the wininit.ini file in the Windows directory.
Some info on that here: http://techsupt.winbatch.com/TS/T000001045F1.html
Seems like there'd be a simple API/reg entry to use, but I don't know of any. _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Tue Jun 15, 2004 4:07 am Post subject: |
|
|
Oh Man!, and the MS KB says this pertains to even 2k and XP!! This may
be the solution completely!!
http://support.microsoft.com/default.aspx?scid=kb;EN-US;140570
Thanks!  _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Tue Jun 15, 2004 4:12 am Post subject: |
|
|
Everything I ran across mentioned NT, but I didn't think it was for the 2K and XP NT version..
Either way, glad to help. _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Tue Jun 15, 2004 6:12 am Post subject: |
|
|
Actually, it may not work on NT based systems. I'm not sure yet. But
it definitely works on 9x based systems. _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Tue Jun 15, 2004 6:56 pm Post subject: |
|
|
Hi Garrett,
Why not use some simple command-line programs that come with Windows
to delete your file(s)?
DEL.EXE
| Code: | Deletes one or more files.
DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
names Specifies a list of one or more files or directories.
Wildcards may be used to delete multiple files. If a
directory is specified, all files within the directory
will be deleted.
/P Prompts for confirmation before deleting each file.
/F Force deleting of read-only files.
/S Delete specified files from all subdirectories.
/Q Quiet mode, do not ask if ok to delete on global wildcard
/A Selects files to delete based on attributes
attributes R Read-only files S System files
H Hidden files A Files ready for archiving
- Prefix meaning not
If Command Extensions are enabled DEL and ERASE change as follows:
The display semantics of the /S switch are reversed in that it shows
you only the files that are deleted, not the ones it could not find. |
RMDIR.EXE
| Code: | Removes (deletes) a directory.
RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path
/S Removes all directories and files in the specified directory
in addition to the directory itself. Used to remove a directory
tree.
/Q Quiet mode, do not ask if ok to remove a directory tree with /S |
_________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Wed Jun 16, 2004 12:27 am Post subject: |
|
|
I don't seem to have either of those files on WinME here, and I don't see
them on the XP cd either.  _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Jun 16, 2004 1:27 am Post subject: |
|
|
Oh That's strange - I thought MS would have retained those because
they were the original commands from MS-DOS.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Wed Jun 16, 2004 1:40 am Post subject: |
|
|
Those commands are built into dos itself. I could use those, but I'm trying
avoid having a dos window pop open on the user unexpectedly.
Anyway, the problem is at least half solved. The wininit.ini will at least
work on 9x system. If it doesn't work on NT systems, there is an api
that does the same thing. I just do not know if VDS 5 can handle this
api yet.
Thanks for the info though  _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Wed Jun 16, 2004 4:52 pm Post subject: |
|
|
Just in case anyone else is interested....
The wininit.ini is good to go on 9x systems. But not for NT systems that
I know of. But! For NT systems, there is an api that does the same thing
as the wininit.ini on 9x systems.
As it turns out, this api merely places an entry in the registry, which NT
reads before it loads dlls and such and either replaces files or deletes
files. So my only question now, is if I write directly to the registry in an
NT system, is there going to be a permissions problem with trying to
write to the registry... If so, then I'll have to work out using the API in
VDS.
| Quote: | Windows NT:
If the dwFlags parameter specifies MOVEFILE_DELAY_UNTIL_REBOOT, MoveFileEx stores the locations of the files to be renamed at reboot under the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\
Control\Session Manager\PendingFileRenameOperations
The key is of type REG_MULTI_SZ. Each rename operation is a pair of NULL-terminated strings. The system uses these registry entries to complete the operation at reboot in the same order that they were issued.
For example, on Windows NT, the following code fragment creates registry entries that delete szDstFile and rename szSrcFile to be szDstFile at reboot:
MoveFileEx(szDstFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
MoveFileEx(szSrcFile, szDstFile, MOVEFILE_DELAY_UNTIL_REBOOT);
The system creates the associated PendingFileRenameOperations entries as follows:
szDstFile\0\0
szSrcFile\0szDstFile\0\0 |
_________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
PGWARE Web Host

Joined: 29 Dec 2001 Posts: 1565
|
Posted: Wed Jun 16, 2004 5:49 pm Post subject: |
|
|
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\
You can't write to HKEY_LOCAL_MACHINE under NT systems (nt, xp, 2000, 2003) unless you have registry read/write permissions.
Under XP only administrator type accounts can write to HKEY_LOCAL.
You're allowed to write and read from HKEY_CURRENT_USER however under restricted accounts without any problems. |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Wed Jun 16, 2004 6:40 pm Post subject: |
|
|
Thanks PK. I'll have to work on the API then and see if that will still work
without admin rights. _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Wed Jun 16, 2004 7:03 pm Post subject: |
|
|
MSDN says:
| Quote: | | This value can be used only if the process is in the context of a user who belongs to the administrator group or the LocalSystem account. |
Looks like ya need admin rights..
| Code: |
REM Delete %%file on reboot.
%%file = C:\testfile.txt
%%MOVEFILE_DELAY_UNTIL_REBOOT = $04
LOADLIB kernel32.dll
%x = @LIB(kernel32,MoveFileExA,INT:,STR:%%file,NIL:,INT:%%MOVEFILE_DELAY_UNTIL_REBOOT)
if @EQUAL(%x,0)
INFO MoveFileEx Failed!
else
INFO MoveFileEx Succeeded!
end
|
_________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Wed Jun 16, 2004 7:37 pm Post subject: |
|
|
Ah damn! I just tried my hand at converting that api and it looks I was
way off!
Say, can someone with either 2K or XP try the following code, reboot and
see if the file gets deleted or not?
| Code: | LIST CREATE,1
LIST ADD,1,TEST
LIST SAVEFILE,1,C:\apitest.txt
LIST CLEAR,1
LIST CLOSE,1
IF @greater(@file(@windir()"\"Wininit.ini,Z),0)
LIST CREATE,3
LIST LOADFILE,3,@windir()"\"Wininit.ini
LIST ADD,3,"NUL=C:\apitest.txt"
LIST SAVEFILE,3,@windir()"\"Wininit.ini
ELSE
LIST CREATE,3
LIST ADD,3,[rename]
LIST ADD,3,"NUL=C:\apitest.txt"
LIST SAVEFILE,3,@windir()"\"Wininit.ini
END |
Thanks, _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Wed Jun 16, 2004 8:28 pm Post subject: |
|
|
No go here on XP.
Might have to stick with a batch file for non admin 2K/XP users.
Could always try MoveFileEx first and if it returns non zero, create the batch file in the startup folder/key. _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
|