Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XCACLS.vbs Editing

Status
Not open for further replies.

djwatts

Programmer
Joined
Nov 10, 2004
Messages
91
Location
GB
Hello All,

We have a domain migration up-coming and we will be re-creating all of our user accounts.

I have been looking at the XCACLS.vbs script and I am going to customize it to our needs. There is a procedure in this script that opens a Output File for editing, the problem is I need to be able to append data to the end of the txt file, I have tried changing the parameters for objFileSystem.OpenTextFile(strAbsoluteFile, 8, TRUE) have changed the 8 to 1,3,8 and toggled the True/False argument, it only ever seems to replace the contents of the file, can anyone help with this???

Thanks



Sub OpenOutputFile()

Dim objFileSystem, MyFile, strAbsoluteFile

If Not blnQuiet then
If debug_on then Wscript.Echo "OpenOutputFile: Enter"
End if

Do
If strOutputFile = "" then Exit Do
set objFileSystem = CreateObject("Scripting.FileSystemObject")
If blnErrorOccurred(" opening a filesystem object. (Msg#4201)") Then
strOutputFile = ""
Exit Do
End if
'Open the file for output
strAbsoluteFile = objFileSystem.GetAbsolutePathName(strOutputFile)
If Not objFileSystem.FileExists(strAbsoluteFile) Then
'If it doesn't exist we try to create it.
Set MyFile = objFileSystem.CreateTextFile(strAbsoluteFile, TRUE)

If blnErrorOccurred(" occurred in getting objFileSystem.CreateTextFile(strAbsoluteFile, TRUE) (Msg#4202)") Then Exit Do

MyFile.Close
End If
set objOutputFile = objFileSystem.OpenTextFile(strAbsoluteFile, 8, TRUE)
If blnErrorOccurred(" opening file " & strAbsoluteFile & ". (Msg#4203)") Then
strOutputFile = ""
Exit Do
End if
Exit Do
Loop

Call blnErrorOccurred(" occurred while in the OpenOutputFile routine. (Msg#4204)")
If Not blnQuiet then
If debug_on then Wscript.Echo "OpenOutputFile: Exit"
End if

End Sub
 
djwatts,

When I look at the script fragment you've listed, I say wait a minute, that could not be right. Then, I look at the xcacls.vbs as released by the ms scripting team, I have a moment of doubt. But I come to the same conclusion. If you ever report bug to ms, you can even quote me. I think they're wrong.

In the sub openoutputfile(), you must insert on error resume next, failing that, the sub would not perform as design.
[tt]
Sub OpenOutputFile()
[red]on error resume next[/red]
Dim objFileSystem, MyFile, strAbsoluteFile
'continue the same as the rest
End Sub
[/tt]
ms scripting team has my more-than-due respect. But, there are occasions I cannot agree with them.

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top