Everyone
(Getting the hang of it)
2003-10-19 08:17 PM
DEL command not deleting read-only files

The Kix DEL command does not seem to want to delete any files marked as read-only.
No error is returned, the file marked for deletion in the script simply doesn't get deleted.

For example, the file test.txt is read-only
The Kix command:
DEL "test.txt"
Will not delete the file, nor will
DEL "test.txt" /h

In order to delete the file, I have to use
shell "cmd /c del test.txt /a:r"

Is there a way to delete read-only files without having to use a shell command?


Mart
(KiX Supporter)
2003-10-19 08:28 PM
Re: DEL command not deleting read-only files

Which version of kix are you using?

Version 4.22 (RC1 for now) supports the deletion of read only files.

Quote from the 4.22 manual:
quote:

DEL can now delete read-only files ('/f')



Kdyer
(KiX Supporter)
2003-10-19 09:53 PM
Re: DEL command not deleting read-only files

SETFILEATTR should do it before the file Deletion.

Kent


Everyone
(Getting the hang of it)
2003-10-19 11:06 PM
Re: DEL command not deleting read-only files

Using 3.63, the version that comes with the NT/2000 resource kit.

Unfortunately I can't upgrade to a beta version. (not authorized to do so)
Also I have no easy way to upgrade. Kix is loaded to each workstation via a batch file at first logon, then several kix scripts are called from the batch file. (just how it was set up long before I got there)

I'll try that SETFILEATTR command.


Sealeopard
(KiX Master)
2003-10-19 11:13 PM
Re: DEL command not deleting read-only files

Please read ABC's of KiXtart board etiquette and message to new forum users , especially Section F.

KiXtart v3.63 is no longer under developemnt and has been superseeded by KiXtart v4.21 with KiXtart v4.22-RC1 the current release candidate.

Therefore, the KiXtart DEL command is behaving as designed and documented for KiXtart v3.63.

It is also recommended to use KiXtart v4.x under Windows 2000/XP/2003 as v3.63 has only limited support for these platforms, e.g. some of the macros will not be set correctly.

Finally, KiXtart v4.x is required for full AD functionality.


Howard Bullock
(KiX Supporter)
2003-10-19 11:19 PM
Re: DEL command not deleting read-only files

There are many ways to upgrade when each computer has the binaries loaded locally.

You definitely should get off of 3.x version.

See the posts in http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=2;t=003344#000000
for some ideas. I believe the FAQ forum also some ideas as well MCA's web site.

I check for the proper verion each and every logon and can uipgrade all client anytime. My web site also has some logon script design thoughts.


Mart
(KiX Supporter)
2003-10-19 11:22 PM
Re: DEL command not deleting read-only files

Even if a beta or RC version is not allowed to be the operational version of kix on your net (which is understandable) you should at least dump 3.x and switch to 4.21. Just like some posts above said better support for the newer OS's and it's the current released version.

If each wksta gets kix copied to it's local drive using a bat file implementing 4.21 should not be that difficult. Just delete the old file(s) and copy the new. No uninstall or install required.

Hopefully 4.22 will be released soon.

[ 19. October 2003, 23:30: Message edited by: R2D2 ]


Mart
(KiX Supporter)
2003-10-19 11:54 PM
Re: DEL command not deleting read-only files

If you follow our advice and switch to 4.21 this should do the trick.

code:
?"Kix version: " + @kix
$rc = GetFileAttr ("c:\test.txt")
?"Error: " + @error + " / " +@SERROR
?"Current attribute settings: " + $rc
Select
Case $rc <> 32
SetFileAttr ("c:\test.txt", 32)
?"Error: " + @error + " / " +@SERROR
Del ("c:\test.txt")
?"Error: " + @error + " / " +@SERROR
Case $rc = 32
Del ("c:\test.txt")
?"Error: " + @error + " / " +@SERROR
EndSelect
Sleep 5

The error checking, kix version and the sleep 5 are there just to see if it completes like it should. All the attribute values are documented in the manual. 32 is archive only, 33 is archive and read only, etc…


Everyone
(Getting the hang of it)
2003-10-19 11:54 PM
Re: DEL command not deleting read-only files

I am aware of all that. It's more not being allowed to upgrade, than not knowing how to.

I appologize for not mentioning the version of Kixtart being used before. As far as the rest of "Section F". For security reasons, I cannot disclose any further details on my network environment.

Aside from waiting on permission to upgrade, I have limitations on upgrading. (SMS and other simular options are beyond my control)

Pretty much the only option I have for upgrading is via the login scripts themselves.

This is a very large network (over 5000 users), with a few dozen different login scripts depending on where users are assigned to. (trying to consolidate this mess down into one script)

A batch file cannot determine the version of Kixtart alread installed on the system. A Kixtart script can determine which version is running, however it cannot copy a new version over the top of itself, because kix32.exe will be in use while the script is running. (actually it can do this, but only if the upgrade code is at the very end of a script, and only one script is being run, however several scripts are currently being run at once)

Version determination is very important due to the volume of users on the network. Having a batch script blindly replace existing Kixtart files every time a user logs on, would result in unacceptable amounts of network traffic during peak logon times (shift changes), and could potentially cause many other problems.

I am considering having a text file copied along with the Kixtart files, and having the batch script copy the newer Kixtart files only if the text file is not present. This is the only feasable option I have been able to come up with thus far. Only obstacle in that is sorting through the mess of login scripts left by those who came before me.

So I'm stuck with 3.63 until authorization is given to upgrade, and must make due with features availible within it until then.


Howard Bullock
(KiX Supporter)
2003-10-19 11:58 PM
Re: DEL command not deleting read-only files

You need to read my batch file. It is the second post of the link I posted above. I use a CRC32 check and replace any file that is not what it should be (version or otherwise.)

[ 20. October 2003, 02:32: Message edited by: Howard Bullock ]


Mart
(KiX Supporter)
2003-10-20 12:01 AM
Re: DEL command not deleting read-only files

quote:

A batch file cannot determine the version of Kixtart already installed on the system.

Yes and no.
We copy a kix.421 file along with the kix files to all our wksta at logon if necessary. The logon.bat files can check for file existence and copy the new files if the file you have it check for is not found.

The script I posted above also works fine with 3.63.

And actually kix doesn’t need to be installed, just copied [Wink]

[ 20. October 2003, 00:05: Message edited by: R2D2 ]


Sealeopard
(KiX Master)
2003-10-20 12:06 AM
Re: DEL command not deleting read-only files

Or, depending on how fast your network is, don't even bother copying the executable to the clients. Just dump everything into the NETLOGON share. Then you don't have to worry whether a client has an incorrect version, no Kixtart at all, or whether somebody tries to break the login script. Granted it adds about 300k of traffic for each user, but, unless you're using dial-up or ISDN, you should be fine with this. It will also make version control easier.

The FAQ Forum contains multiple threads about this.

[ 20. October 2003, 00:24: Message edited by: sealeopard ]


Everyone
(Getting the hang of it)
2003-10-20 12:06 AM
Re: DEL command not deleting read-only files

Thanks, didn't catch that the first time I read it. Only saw the O/S version checking.

Very good idea with the /D switch on the xcopy command, didn't even think of that one.

That should work very good.

Thanks again.


Everyone
(Getting the hang of it)
2003-10-20 12:20 AM
Re: DEL command not deleting read-only files

Yeah, it would be much easier like that, I've thought of that option before. ;-)

Bandwith isn't that much an issue... however with over 5000 users, mass amounts of open sessions on a server causes problems with the server.

Open sessions on the server often remain, even after the program has stopped running. So you end up with a bunch of workstations connected to your servers, not doing anything, but not letting other workstations do anything either. Some times clearing the sessions will fix it, some times you have to reboot.

I had a small one-way messaging program being run off of a file server on each workstation via login script once. After the program was loaded into memory, the workstations weren't releasing there sessions on the file share. There was no reason the sessions should be kept open, and not every workstation kept them open, but enough of them did to keep crashing it. Ended up having to copy the program to each workstation, instead of running it off the server.

Probably wouldn't be a problem in a smaller environment.

Wasn't very fun.

quote:

Or, depending on how fast your network is, don't even bother copying the executable to the clients. Just dump everything into the NETLOGON share. Then you don't have to worry whether a client has an incorrect version, no Kixtart at all, or whether somebody tries to break the login script. Granted it adds about 300k of traffic for each user, but, unless you're using dial-up or ISDN, you shoudl eb fine with this. It will also make verison control easier.

The FAQ Forum contains multiple threads about this.

--------------------
Jens



Everyone
(Getting the hang of it)
2003-10-20 12:22 AM
Re: DEL command not deleting read-only files

Did I say "installed"? I meant copied. ;-)

quote:
And actually kix doesn’t need to be installed, just copied



Sealeopard
(KiX Master)
2003-10-20 12:23 AM
Re: DEL command not deleting read-only files

The session was kept open because the executable loaded from the server was in use. In the case of a login script, however, the executables would be closed after a couple of seconds, thus releasing that particular session again.

Mart
(KiX Supporter)
2003-10-20 12:31 AM
Re: DEL command not deleting read-only files

No matter if you choose to run kix from netlogon or locally on the system it will call scripts from netlogon so you will always have a session open until the kix process is completed.

We had some problems with the kix executable getting corrupt for some strange unknown reason after a few months when ran from netlogon so nobody would get the script executed at logon. For this reason we decided to copy kix to the local drive. Affects only the specific wksta when the kix executable gets damaged.


Everyone
(Getting the hang of it)
2003-10-20 12:40 AM
Re: DEL command not deleting read-only files

That's weird.

Correct, always going to have sessions open. However, they should close faster loading only a few 2-3K .kix files, instead of loading kix32.exe AND a few 2-3K .kix files.

Many pros and cons to either method of running it.


Howard Bullock
(KiX Supporter)
2003-10-20 01:45 AM
Re: DEL command not deleting read-only files

My method is still the best. [Wink] IMHO YMMV

Everyone
(Getting the hang of it)
2003-10-20 01:57 AM
Re: DEL command not deleting read-only files

Looks that way so far. [Wink]

Everyone
(Getting the hang of it)
2003-10-20 04:23 AM
Re: DEL command not deleting read-only files

So back to the original subject..

My solution based on kdyer and r2d2's suggestions, and my circumstances, is:

IF EXIST ("test.txt")
SETFILEATTR ("test.txt",128)
DEL "test.txt"
ENDIF

Which looks like the easiest way to do what I need to do.

Set the file attributes to normal, so the DEL command can delete it with ease. (the file I'm deleting has attributes that vary from system to system. There is no need to know the attributes of the file, hence no GETFILEATTR command)

Thanks all.


NTDOCAdministrator
(KiX Master)
2003-10-20 04:49 AM
Re: DEL command not deleting read-only files

Here is the code with a little error or success checking. Should work fine for KiXtart 3.63

break on
$FileCheck='C:\TEMP\TEST.TXT'
if exist ($FileCheck)
? 'Found file : '
$SetAttrib=setfileattr($FileCheck,128)
? 'Setting file attrib was: '+@error+' '+@serror
del $FileCheck
? 'File deletion success was: '+@error+' '+@serror
else
? 'Unable to locate file '+$FileCheck
endif


Everyone
(Getting the hang of it)
2003-10-20 05:20 AM
Re: DEL command not deleting read-only files

Thanks.

I don't have success/failure messages in the script this is being used in. I have it appending data to a log on a file server.

Currently success/failure is checked with a redundant IF EXIST command toward the end of the script.

I'll post the full script to the scripts forum some time tomorrow when I'm in the office.

It's currently 100% effective, I'm just looking to tweak it and make it more effecient.


Sealeopard
(KiX Master)
2003-10-20 03:51 PM
Re: DEL command not deleting read-only files

quote:
I'm just looking to tweak it and make it more effecient
Then you should upgrade to KiXtart v4.21 [Wink]


Mart
(KiX Supporter)
2003-10-20 09:54 PM
Re: DEL command not deleting read-only files

quote:
quote:

I'm just looking to tweak it and make it more effecient

Then you should upgrade to KiXtart v4.21

LOL [Big Grin] but true.


Kdyer
(KiX Supporter)
2003-10-20 10:29 PM
Re: DEL command not deleting read-only files

Upgrading KiXtart (have used the the second link with "locked down" systems):

KiXtart Deployment

Re-Write of the KIX32.EXE Deployment tool

KiXtart FAQ & How to's

Alternatively, rather than distributing the KIX32.EXE/WKIX32.EXE file to the clients, you can run these on the Logon server. However, you have to change your client profiles from NTLOGON.BAT to KIX32/WKIX32 and the KiXtart script will from the from the NETLOGON folder.

HTH,

Kent