1. Problem with dos commands
Hilp (combination of Hi and help),
I had a need for a simple encryption/decryption program and decided to
write it yesterday. I thought it would go quickly and it did, except
I wanted be able to rename files as part of the encryption process.
That's when the project headed south. Only one of the dos commands
has worked -- the copy command. "rename" fails.
When the rename command failed to do anything at all, I decided to
finish the project using copy to duplicate the files with a new name,
then del the original files, but the del didn't work. Arrgh. So, I
incorporated Daniel Bernstein's dos.e and those commands didn't work
either. I tried the reference-manual suggested SET
CAUSEWAY=LOWMEM:80. Again, no luck. Here's the routine with the
troublesome code:
======================================================
function ProcessFiles(sequence path_name,sequence entry)
integer go
sequence src,dest
if wildcard_file("*.bat",entry) or
wildcard_file("*.com",entry) or
wildcard_file("*.exe",entry) then
--do nothing
else
go=Krypt(path_name & entry) --read in file, encrypt, write back
to file
trace(1)
if equal(mode,3) then --Note: mode 3 is set when the user decides
to auto-rename the selected files
src=path_name & entry
dest=path_name & NewName(entry) --Newname() generates a
neutral name, e.g. xaqf0000.txt
--system("rename " & src & ' ' & dest,2) --failed (dos
command)
--go=copy(src,dest) --failed
(dos.e command)
--go=delete(src) --failed
(dos.e command)
--system("copy " & src & ' ' & dest,2) --worked! (dos
command)
--system("del " & src,2) --failed (dos
command)
end if
end if
return NOPROBLEM
end function
======================================================
I am running Windows 98 and have Norton Systemworks 2000 on it.
Any ideas?
--DB James (Quark)
2. Re: Problem with dos commands
On Sun, 21 May 2000 15:39:50 -0400, DB James <dbjames at PENN.COM> wrote:
>Hilp (combination of Hi and help),
Hellok (combination of hello and OK :) )
>I had a need for a simple encryption/decryption program and decided to
>write it yesterday...
>Only one of the dos commands has worked -- the copy command.
>"rename" fails.
>I am running Windows 98 and have Norton Systemworks 2000 on it.
I don't think it's the operating system that's the problem here, more the
access permissions on the file you're trying to rename / delete.
At a DOS command line type:
attrib problemfilename.here
...and see if the file's marked as read-only (R), hidden (H) or system (S).
Any of these would stop system("del...",2) from deleting the file or
system("ren...",2) from renaming. Ignore the Archive (A) attribute.
The less likely possibility is that there's something wrong with the format
of the path variable in your program.
HTH,
Carl
--
[.sig done runner]