xcacls.vbs stops in each iteration

Discussion in 'Scripting' started by tom.doniphon, Mar 11, 2008.

  1. tom.doniphon

    tom.doniphon Guest

    When i execute xcacls.vbs iterativement in batch mode the batch stops in each
    iteration.How could i solve it?
    Many thanks in advance
     
    tom.doniphon, Mar 11, 2008
    #1
    1. Advertisements

  2. Hard to say - you need to post your code.
     
    Pegasus \(MVP\), Mar 11, 2008
    #2
    1. Advertisements

  3. tom.doniphon

    tom.doniphon Guest

    First thanks for your attention.
    I've two windows cmd files. One call the other one.
    The code of the first cmd file (file name is "test.cmd") is:

    echo on
    call testaux.cmd machine1 machine2 machine3 machine4 machinen

    The code of the called cmd file (file name is "testaux.cmd") is:

    echo on
    :SCAN

    if "%1"=="" goto END

    cscript c:\windows\xcacls.vbs \\%1\d$\directory /g %1\userx:m /f /t /e

    shift

    goto SCAN

    :END

    The problem: in each iteration the process stops. What can i do?Thanks again.
     
    tom.doniphon, Mar 12, 2008
    #3
  4. The "stop" probably occurs in xcacls.vbs but since you
    did not post the contents of this file, I cannot tell.

    For easier maintenance you should consider combining
    your two batch files in one single file like so:

    @echo off
    for %%a in (machine1 machine2 machine3 machine4 machinen) do (
    cscript c:\windows\xcacls.vbs \\%%a\d$\directory /g %%a\userx:m /f /t /e
    )
     
    Pegasus \(MVP\), Mar 12, 2008
    #4
  5. tom.doniphon

    tom.doniphon Guest

    "Stops" means hang the processing with the message :

    **************************************************************************
    Directory: \\machinen\f$DIRECTORYSHARED
    Granting NTFS rights (M access for This Folder, Subfolders and Files) for
    "DOMAIN\USERX"
    Completed successfully.
    **************************************************************************

    and not continue with the next item.
    Thanks for your attention.
     
    tom.doniphon, Mar 12, 2008
    #5
  6. tom.doniphon

    tom.doniphon Guest

    The code of my "xcacls.vbs" is the corresponding to the 5.2 version of
    "xcacls.vbs".
    Thanks again.
     
    tom.doniphon, Mar 12, 2008
    #6
  7. You should have posted this information at the very
    beginning - it is absolutely essential!

    You now need to find out where the process hanges,
    by working backwards through the code, one step at
    a time. Start with this modified batch file and report
    the result:
    @echo off
    for %%a in (machine1 machine2 machine3 machine4 machinen) do (
    echo Processing "%%a"
    cscript c:\windows\xcacls.vbs \\%%a\d$\directory /g %%a\userx:m /f /t /e
    pause
    )
     
    Pegasus \(MVP\), Mar 12, 2008
    #7
  8. tom.doniphon

    tom.doniphon Guest

    Thanks for your simplificated script but the hang continues.
     
    tom.doniphon, Mar 12, 2008
    #8
  9. Please try a little harder. The modified batch file has
    several diagnostic messages - I put them there so that
    you can report precisely what you see on the screen!
     
    Pegasus \(MVP\), Mar 12, 2008
    #9
  10. tom.doniphon

    tom.doniphon Guest

    When I execute the script that you sent me I obtain:

    echo Processing "machine1"
    cscript c:\windows\xcacls.vbs \\machine1\SHAREDDIR /g domain\userx:m /f /t /e
    pause
    )
    Processing "machine1"
    Microsoft (R) Windows Script Host versión 5.6
    Copyright (C) Microsoft Corporation 1996-2001. Reservados todos los derechos.

    Starting XCACLS.VBS (Version: 5.2) Script at 13/03/2008 11:36:54

    Startup directory:
    "C:\admi\batchperms"

    Arguments Used:
    Filename = "\\machine1\SHAREDDIR"
    /F (All Files under current directory)
    /T (Traverse Directories)
    /E (Edit ACL leaving other users intact)
    /G (Grant rights)
    domain\USERX:M



    **************************************************************************
    Directory: \\machine1\SHAREDDIR
    Granting NTFS rights (M access for This Folder, Subfolders and Files) for
    "DOMAIN\SHAREDDIR"
    Completed successfully.
    **************************************************************************

    ....and then stops! instead of continuing with the habitual:

    Operation Complete
    Elapsed Time: 23,34375 seconds.

    Ending Script at 13/03/2008 11:47:08

    and it doesn't continue with the following item (machine2, machine3, etc)

    ( I reiterate you my gratefulness)
     
    tom.doniphon, Mar 13, 2008
    #10
  11. Well, we're making a little progress. Your report suggests
    that xcacls.vbs does not run right through to completion. The
    first question I would ask is whether this the original version
    of xcacls.vbs or whether is it a modified copy? I find it difficult
    to accept that Microsoft-released tool has a bug in it, especially
    one that has been widely used since 2001.

    The next step consists of finding out WHERE exactly the
    script hangs. Here is how you can do it:
    1. Save the original version of xcacls.vbs in xcacls.org.
    2. Use a text editor such as notepad.exe to edit xcacls.vbs.
    3. Replace the blank lines #1107, #1124 and #1127 with
    the following lines. Do NOT insert extra lines!
    ===================
    End Select
    WScript.Echo "*** Line 1107"
    Exit Do 'We really didn't want to loop
    Loop
    'ClearObjects that could be set and aren't needed now

    Set objOwner = Nothing
    Set objFileSecSetting = Nothing
    Set objmethod = Nothing
    Set objSecDescriptor = Nothing
    Set objtrustee = Nothing
    Set objInParam = Nothing
    Set objOutParams = Nothing
    Set OldAceObj = Nothing
    Set ObjNewAce = Nothing
    Set NewobjDescriptor = Nothing
    Set objTempTrustee = Nothing
    Set RetVal = Nothing
    WScript.Echo "*** Line 1124"
    Call blnErrorOccurred(" occurred while in the SetACLForObject routine.
    (Msg#539)")
    If debug_on then Call PrintMsg("SetACLForObject: Exit")
    WScript.Echo "*** Line 1127"
    End Sub

    ===================
    4. Rerun the script and report what you see on the screen.

    Please note: This will NOT solve your problem. It will only
    give you some hints as to where the problem might lie.
    Further trouble-shooting will be necessary.
     
    Pegasus \(MVP\), Mar 13, 2008
    #11
  12. tom.doniphon

    tom.doniphon Guest

    Hello again,
    Once modified following your indications the file xcacls.vbs, the script
    output is:

    C:\admi\batchangeperm>echo on

    C:\admi\batchangeperm>for %a in (machine1 machine2 machine3) do (
    echo Processing "%a"
    cscript c:\windows\xcacls.vbs \\%a\SHAREDDIR /g domain\USERX:m /f /t /e
    rem pause
    )

    C:\admi\batchangeperm>(
    echo Processing "machine1"
    cscript c:\windows\xcacls.vbs \\machine1\SHAREDDIR /g domain\USERX:m /f /t /e
    rem pause
    )
    Processing "machine1"
    Microsoft (R) Windows Script Host versión 5.6
    Copyright (C) Microsoft Corporation 1996-2001. Reservados todos los derechos.

    Starting XCACLS.VBS (Version: 5.2) Script at 13/03/2008 16:41:06

    Startup directory:
    "C:\admi\batchangeperm"

    Arguments Used:
    Filename = "\\machine1\SHAREDDIR"
    /F (All Files under current directory)
    /T (Traverse Directories)
    /E (Edit ACL leaving other users intact)
    /G (Grant rights)
    domain\USERX:M



    **************************************************************************
    Directory: \\machine1\SHAREDDIR
    Granting NTFS rights (M access for This Folder, Subfolders and Files) for
    "MITYC\APPDGTTI"
    Completed successfully.
    *** Line 1107
    *** Line 1124
    *** Line 1127
    **************************************************************************
    ...and stops...(I wait your news)
    greetings
    Doniphon
     
    tom.doniphon, Mar 13, 2008
    #12
  13. We're getting a little closer. By the way I note that you did
    not reply to my question if this was the original version of
    the script or a modified version.

    Here are a few more markers to place. This time you will
    have to insert six extra lines. Starting at line # 535, the code
    should look like so:
    ==================
    'We already checked for existance so we will assume it exists.
    If g_Used Or r_used Or p_Used Or d_used Or o_used Or i_used Then
    Call SetACLForObject(AbsPath, IsItAFolder)
    DisplayIt = False
    End If
    WScript.Echo "*** Line 540"
    If DisplayIt Then
    Call DisplayThisACL(AbsPath)
    End If
    WScript.Echo "*** Line 544"
    Call
    PrintMsg("**************************************************************************")
    WScript.Echo "*** Line 546"
    Exit Do
    Loop
    WScript.Echo "*** Line 549"
    Call blnErrorOccurred(" occurred while in the DoTheWorkOnThisItem
    routine. (Msg#301)")
    WScript.Echo "*** Line 551"
    If debug_on then Call PrintMsg("DoTheWorkOnThisItem: Exit")
    WScript.Echo "*** Line 553"
    ===================
    Again you should run the modified program and report what
    you see on the screen. Based on your report, we'll have to
    drill down further.
     
    Pegasus \(MVP\), Mar 13, 2008
    #13
  14. tom.doniphon

    tom.doniphon Guest

    Hi,
    the new script output is:

    C:\admi\batchangeperm>nchangeperm

    C:\admi\batchangeperm>echo on

    C:\admi\batchangeperm>for %a in (machine1 machine2 machine3 machine4) do (
    echo Processing "%a"
    cscript c:\windows\xcacls.vbs \\%a\SHAREDDIR /g domain\USERX:m /f /t /e
    rem pause
    )

    C:\admi\batchangeperm>(
    echo Processing "machine1"
    cscript c:\windows\xcacls.vbs \\machine1\SHAREDDIR /g domain\USERX:m /f /t /e
    rem pause
    )
    Processing "machine1"
    Microsoft (R) Windows Script Host versión 5.6
    Copyright (C) Microsoft Corporation 1996-2001. Reservados todos los derechos.

    Starting XCACLS.VBS (Version: 5.2) Script at 14/03/2008 10:52:04

    Startup directory:
    "C:\admi\batchangeperm"

    Arguments Used:
    Filename = "\\machine1\SHAREDDIR"
    /F (All Files under current directory)
    /T (Traverse Directories)
    /E (Edit ACL leaving other users intact)
    /G (Grant rights)
    domain\USERX:M



    **************************************************************************
    Directory: \\machine1\SHAREDDIR
    Granting NTFS rights (M access for This Folder, Subfolders and Files) for
    "domain\USERX"
    Completed successfully.
    *** Line 1107
    *** Line 1124
    *** Line 1127
    *** Line 540
    *** Line 544
    **************************************************************************
    *** Line 546
    *** Line 549
    *** Line 551
    *** Line 553

    ....and stops...

    P.D. The xcacls.vbs version is the 5.2 version downloaded from "microsoft"
    (thanks and expecting news)
     
    tom.doniphon, Mar 14, 2008
    #14
  15. Well, we carry on in the same way. Here is the bunch of lines
    starting at Line # 317. I'm sure you get the general idea by now.
    =====================
    'If a folder is found with the same name, then we work it as a folder and
    include files under it.
    Select Case DoesPathNameExist(InitialfilenameAbsPath)
    Case 1 'Directory
    Call DoTheWorkOnThisItem(InitialfilenameAbsPath, True)
    WScript.Echo "*** Line 321"
    If t_Used Or f_Used Or s_Used Then
    WScript.Echo "*** Line 323"
    Call DoTheWorkOnEverythingUnderDirectory(InitialfilenameAbsPath)
    WScript.Echo "*** Line 325"
    End If
    Case 2 'File
    Call DoTheWorkOnThisItem(InitialfilenameAbsPath, False)
    Case Else
    Call PrintMsg("Error: File/Directory """ &
    DisplayPathString(InitialfilenameAbsPath) & """ not found.")
    End Select
    End If
    Case Else
    WScript.Echo "*** Line 334"
    Call PrintMsg("")
    WScript.Echo "*** Line 336"
    Call PrintMsg(intOpMode)
    WScript.Echo "*** Line 338"
    End Select
    WScript.Echo "*** Line 340"

    Call blnErrorOccurred(" occurred while in the main routine of the script.
    (Msg#103)")
    WScript.Echo "*** Line 343"
    If debug_on then Call PrintMsg("Main: Exit")
    WScript.Echo "*** Line 345"
    Exit Do 'We really didn't want to loop
    Loop
    WScript.Echo "*** Line 348"
    'ClearObjects that could be set and aren't needed now
    =====================
     
    Pegasus \(MVP\), Mar 14, 2008
    #15
  16. tom.doniphon

    tom.doniphon Guest

    The new result is:

    C:\admi\batchangeperm>nchangeperm

    C:\admi\batchangeperm>echo on

    C:\admi\batchangeperm>for %a in (machine1 machine2 machine3) do (
    echo Processing "%a"
    cscript c:\windows\xcacls.vbs \\%a\SHAREDDIR /g domain\USERX:m /f /t /e
    rem pause
    )

    C:\admi\batchangeperm>(
    echo Processing "machine1"
    cscript c:\windows\xcacls.vbs \\machine1\SHAREDDIR /g domain\USERX:m /f /t /e
    rem pause
    )
    Processing "machine1"
    Microsoft (R) Windows Script Host versión 5.6
    Copyright (C) Microsoft Corporation 1996-2001. Reservados todos los derechos.

    Starting XCACLS.VBS (Version: 5.2) Script at 14/03/2008 12:33:25

    Startup directory:
    "C:\admi\batchangeperm"

    Arguments Used:
    Filename = "\\machine1\SHAREDDIR"
    /F (All Files under current directory)
    /T (Traverse Directories)
    /E (Edit ACL leaving other users intact)
    /G (Grant rights)
    domain\USERX:M

    **************************************************************************
    Directory: \\machine1\SHAREDDIR
    Granting NTFS rights (M access for This Folder, Subfolders and Files) for
    "domain\USERX"
    Completed successfully.
    *** Line 1107
    *** Line 1124
    *** Line 1127
    *** Line 540
    *** Line 544
    **************************************************************************
    *** Line 546
    *** Line 549
    *** Line 551
    *** Line 553
    *** Line 321
    *** Line 323

    and stops
     
    tom.doniphon, Mar 14, 2008
    #16
  17. Ok, you appear to have located the subroutine that causes the
    problem. It's called
    "Sub DoTheWorkOnEverythingUnderDirectory(ByVal ThisPath)"
    and it starts on about Line #392.

    You now need to insert a number of "wscript.echo" lines in this
    subroutine, taking good care to insert the correct line number.
    After a few tries you will find out how far the script gets in this
    subroutine. In your next reply you should report which is the last
    line of code that gets executed.
     
    Pegasus \(MVP\), Mar 14, 2008
    #17
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.