Page 1 of 2 12>
Topic Options
#116960 - 2004-03-28 11:10 AM InUse() - Function to remove in use files
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11577
Loc: CA
I would like to see a new function added to KiXtart that would allow for the COPY/MOVE/DELETE of in use files.

Further information can be reviewed here.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/movefileex.asp

http://www.jsiinc.com/subk/tip5300/rh5378.htm

You can add a single entry into this location with KiXtart to delete a file that is currently locked, but you can't seem to add multiple entries possibly due to the use of NULL

The program MoveEX can if run multiple times can add multiple files to the list as marked for DELETION on the next reboot.

Files are not deleted by this process live, this happens after a reboot of the system.

The Key location is here
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations

The new function should support Adding entries for Copy/Move/Delete as well as removal of current entries.

Top
#116961 - 2004-03-28 03:29 PM Re: InUse() - Function to remove in use files
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
See the UDF Forum under UpdateFileOnReboot()- Schedules a file to be replaced on reboot.

I will update this function to include file removal if only one parameter is being supplied to it.
_________________________
There are two types of vessels, submarines and targets.

Top
#116962 - 2004-03-28 09:56 PM Re: InUse() - Function to remove in use files
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11577
Loc: CA
Yes, I've seen the UDF, but I would like KiXtart to be able to deal with MULTIPLE files/folders just as the INUSE program from Microsoft does. I can easily manage any operation on a single file, it's the multiple files/folders that is an issue.
Top
#116963 - 2004-03-29 05:11 AM Re: InUse() - Function to remove in use files
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
It does support multiple files. It will always append to the existing content of the PendingFileRenameOperations registry value. It currently just doesn't support the removal of in-use files, just the replacement.

Edited by sealeopard (2004-03-29 05:12 AM)
_________________________
There are two types of vessels, submarines and targets.

Top
#116964 - 2004-07-05 07:56 AM Re: InUse() - Function to remove in use files
Dann Cox Offline
Fresh Scripter

Registered: 2002-01-18
Posts: 11
Loc: Nanaimo, BC, Canada
Jens,
I've been trying to do just this, no success before. As mentioned at the top of this thread, Nulls seem to be the catch. I haven't found a way to write a null string to this key, which is required as the second string to delete a file. I'm hoping, from your post here, that you have a way!

[Topic closed by moderator because it is posted to wrong forum]


Edited by Les (2004-07-05 03:38 PM)
_________________________
Dann Cox
Infrastructure Administrator,
School District 68
Nanaimo, BC, Canada
mailto:dcox@sd68.bc.ca
(250) 741-5270

Top
#116965 - 2004-11-26 10:13 AM Re: InUse() - Function to remove in use files
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11577
Loc: CA
I still don't see that your UDF is able to handle the removal of multiple files correctly, so I still opt to ask/suggest that a similar function as the INUSE.EXE has be added to KiXtart.

Top
#116966 - 2004-11-26 02:10 PM Re: InUse() - Function to remove in use files
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
If you're talking about my UDF, it only deals with the replacement of files during reboot.
_________________________
There are two types of vessels, submarines and targets.

Top
#116967 - 2004-11-26 03:03 PM Re: InUse() - Function to remove in use files
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4945
Loc: Leatherhead, Surrey, UK
It's an interesting problem.

Null values are illegal in REG_MULTI_SZ records - try adding one manually and REGEDIT will bitch about it and remove the null string.

Top
#116968 - 2004-11-26 03:25 PM Re: InUse() - Function to remove in use files
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4945
Loc: Leatherhead, Surrey, UK
...but I have a way to do it

[update]
Damnit! I had a solution but it writes in ASCII, and the registry strings need to be UNICODE


Edited by Richard H. (2004-11-26 04:30 PM)

Top
#116969 - 2004-12-07 07:56 AM Re: InUse() - Function to remove in use files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
what is this problem you talk about?
_________________________
!

download KiXnet

Top
#116970 - 2004-12-07 08:55 AM Re: InUse() - Function to remove in use files
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11577
Loc: CA
Jens,

Quote:

If you're talking about my UDF, it only deals with the replacement of files during reboot.




I've tried a few methods but I'm unable to get your udf to properly handle multiple files for replacement either. As far as I can tell this requires the nul value which I don't think KiXtart can do natively.

If I'm wrong that's cool, please post a valid working example.


Think Ruud could easily add this to KiXtart though with very minimal effort and size increase. Have seen code around 20k to do this I think, but a lot of that size is just the fact of creating the EXE in the first place I would guess, so the increase for the KiXtart EXE would probably only increase a very small amount.

Top
#116971 - 2004-12-07 09:32 AM Re: InUse() - Function to remove in use files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
so, what's wrong with the pipe-character?
doesn't it write null to the regvalue?
_________________________
!

download KiXnet

Top
#116972 - 2004-12-07 11:13 AM Re: InUse() - Function to remove in use files
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4945
Loc: Leatherhead, Surrey, UK
Quote:

so, what's wrong with the pipe-character?
doesn't it write null to the regvalue?




No, for two reasons. First, two pipes together "||" are interpreted as a pipe character in the data rather than a null field.

Second, have you tried using Regedit to add a null entry to the value? It removes it and states that null values are not allowed in REG_MULTI_SZ strings.

You *can* write them. I've done it using StdRegProv and SetMultiStringValue along with my binary data UDFs.

The problem is that the values need to be (sort of) UNICODE.

I got part way through writing the ASCII -> UNICODE conversion stuff, but "real work" has intervened and as this is not something I need right now I have had to drop it.

If anyone would like to pick it up and complete it, here is what I have so far...
Code:
Break ON
$=SetOption("Explicit","ON")
$=SetOption("WrapAtEOL","ON")

udfAppendMultiSZ(".","HKCU","Software\KiXtart\Testing","RMSZKEY","fooBAR")
If @ERROR "ERROR: " @ERROR ": " @SERROR EndIf

Exit @ERROR

Function udfAppendMultiSZ($sComputer,$sHive,$sKey,$sValueName,$aValues)
Dim $iResult
Dim $aOldValues
Dim $iHiveID
Dim $oReg
Dim $iIndex

Select
Case $sHive="HKCU" or $sHive="HKEY_CURRENT_USER"
$iHiveID=&80000001
Case $sHive="HKLM" or $sHive="HKEY_LOCAL_MACHINE"
$iHiveID=&80000002
Case "Default"
Exit 1
EndSelect

$aOldValues=ReadValue("\\"+$sComputer+"\"+$sHive+"\"+$sKey,$sValueName)
If @ERROR Exit @ERROR EndIf

If VarType($aValues) & 8192 $aValues=Join($aValues,"|") EndIf
If $aOldValues<>"" $aValues=$aOldValues+"|"+$aValues EndIf

$aValues ?

$oReg=GetObject(
"winmgmts:{impersonationLevel=impersonate}!\\"+
+$sComputer
+"\root\default:StdRegProv")
If @ERROR Exit @ERROR EndIf
$aValues=Split($aValues,"|")
For $iIndex=0 to UBound($aValues)
$aValues[$iIndex]=ASCIItoUNICODE($aValues[$iIndex])
Next
Exit $oReg.SetMultiStringValue($iHiveID,$sKey,$sValueName,$aValues)

EndFunction

; Convert an ASCII string to a UNICODE string
Function ASCIItoUNICODE($s)
Dim $oStream,$adTypeBinary,$adTypeText

$adTypeBinary=1
$adTypeText=2

$oStream=CreateObject("ADODB.Stream")
If @ERROR Exit @ERROR EndIf


$oStream.Type=$adTypeBinary
$oStream.Open

;$oStream.Write(udfIntToByte(255))
;$oStream.Write(udfIntToByte(254))
While $s <> ""
$oStream.Write(udfIntToByte(Asc($s)))
$oStream.Write(udfIntToByte(0))
$s=SubStr($s,2)
Loop
; Write end of string sentinel
$oStream.Write(udfIntToByte(0))
$oStream.Write(udfIntToByte(0))
$oStream.SetEOS

$oStream.Position=0

$ASCIItoUNICODE=$oStream.Read($oStream.Size)
$oStream.Close
"Data type now: " VarTypeName($ASCIItoUNICODE) ?
Exit 0

EndFunction

; Convert a single integer to a byte array
Function udfIntToByte($i)
Dim $oStream,$adTypeBinary,$adTypeText

$adTypeBinary=1
$adTypeText=2

$oStream=CreateObject("ADODB.Stream")
If @ERROR Exit @ERROR EndIf

$i=CInt($i) & 255

$oStream.Type=$adTypeText
$oStream.CharSet="unicode"
$oStream.Open
$oStream.WriteText(" "+Chr($i))
$oStream.Position=0
$oStream.Type=$adTypeBinary

If $i
$oStream.Position=$oStream.Size-2
Else
$oStream.Position=$oStream.Size-1
EndIf
$udfIntToByte=$oStream.Read(1)
$oStream.Close
Exit 0

EndFunction



The problem is that the ASCIItoUNICODE function converts the string OK, but because it ends up as a BYTE ARRAY the .SetMultiStringValue method rejects the data.

I've also tried reading the data back from the converter using .ReadText with a charset of Unicode. While this returns a string is appears to get set back to an ASCII type which kind of defeats the object.

Top
#116973 - 2005-12-15 02:33 AM Re: InUse() - Function to remove in use files
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11577
Loc: CA
Has anyone heard anything from Ruud about this?

I end up wanting/needing this type of support from KiX quite often now.
 

Top
#116974 - 2005-12-15 06:36 PM Re: InUse() - Function to remove in use files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
you talking about inuse() stuff or what?
_________________________
!

download KiXnet

Top
#116975 - 2005-12-15 10:11 PM Re: InUse() - Function to remove in use files
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11577
Loc: CA
Yes, I'd like to see KiXtart natively support a file inuse type function that would alter the registry properly and allow files to be removed/replaced on reboot.
 

Top
#116976 - 2006-01-06 10:26 PM Re: InUse() - Function to remove in use files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
Done in 4.52 Beta 2
_________________________
!

download KiXnet

Top
#116977 - 2006-01-06 11:58 PM Re: InUse() - Function to remove in use files
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11577
Loc: CA
Cool, I'll test this and the RD and post back.
Top
#116978 - 2006-01-14 12:13 PM Re: InUse() - Function to remove in use files
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11577
Loc: CA
Okay took me a while but finally did some testing.

Well as it turns out Ruud didn't tell us what that NEW switch was in 4.52 beta 2 for DEL and MOVE

From the readme for 4.52 beta 2
Quote:

6) Added an option to MOVE and DEL to postpone the actual file operation until
the next re-boot. This enables you to replace or delete files that are in
use. Note that this option requires the user to have administrative
privileges.





As it turns out the switch to use is /P

Using DEL and MOVE with /P worked as expected. It placed valid entries for single or multiple files into the

'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager'
PendingFileRenameOperations

Files were deleted on reboot, or moved to new location.


THANK YOU RUUD - Really nice to finally have this working. Greatly appreciated.
 

 

Top
#116979 - 2006-01-14 12:41 PM Re: InUse() - Function to remove in use files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
hmm...
the beta2 post is screwed up now but nonetheless, in the notes ruud did say the switch:
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=154281
_________________________
!

download KiXnet

Top
Page 1 of 2 12>


Moderator:  Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 142 anonymous users online.
Newest Members
KatieQuinn, Brennnnn, MKubicsek, xguixa, mdress
17681 Registered Users

Generated in 0.044 seconds in which 0.012 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org