Announcement

Collapse
No announcement yet.

Help needed with looping my script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help needed with looping my script

    Hi all.

    I am on with a project to amend 13 .xml files so the "Task Scheduler" can import them.

    I have made a script which works well and amends the chosen .xml file.

    Code:
    -- Get User Name and SID Number
    User = System.GetLANInfo ()
    UserHost = User.Host
    User = System.GetLANInfo()
    UserName = String.Concat(UserHost,"\\".. User.User);
    SIDNumber = System.GetUserSID(User.User);
    -------------------------------------------------------------------------------------------------------------
    -- Load .xml Document 01
    xml_doc_table = TextFile.ReadToTable("C:\\DISM_Win10_x64\\schedule dtasks\\01Mountinstallwim.xml");
    xml_doc_all = Table.Concat(xml_doc_table, "\r\n", 1, TABLE_ALL);
    xml_doc_line_5 = Table.Concat(xml_doc_table, "", 5, 5);
    xml_doc_line_11 = Table.Concat(xml_doc_table, "", 11, 11);
    -- End Of - Load .xml Document 01
    -------------------------------------------------------------------------------------------------------------
    -- Isolate The Old User Name
    LeftAuthorRemoved = String.Mid(xml_doc_line_5, 13, -1); -- including gaps
    RemainingStringLenght = String.Length(LeftAuthorRemoved);
    OldUserName = String.Left(LeftAuthorRemoved, RemainingStringLenght -10);
    -- End Of - Isolate The Old User Name
    -------------------------------------------------------------------------------------------------------------
    -- Isolate The Old SID Number
    LeftUserIDRemoved = String.Mid(xml_doc_line_11, 15, -1); -- including gaps
    RemainingStringLenght = String.Length(LeftUserIDRemoved);
    OldSIDNumber = String.Left(LeftUserIDRemoved, RemainingStringLenght -10);
    -- End Of - Isolate The Old SID Number
    -------------------------------------------------------------------------------------------------------------
    -- Amend Line 5
    xmlDocument_NewLine_5 = String.Replace(xml_doc_all, OldUserName, UserName, false);
    --End of - Amend Line 5
    ------------------------------------------------------------------------------------------------------------------
    -- Amend Line 11
    New_xml_Doc = String.Replace(xmlDocument_NewLine_5, OldSIDNumber, SIDNumber, false);
    --End of - Amend Line 1
    ------------------------------------------------------------------------------------------------------------------
    -- Create new .xml Document = 01Mountinstallwim.xml
    TextFile.WriteFromString("C:\\DISM_Win10_x64\\scheduledtasks\\amended\\01Mountinstallwim.xml", New_xml_Doc, false);
    -- End Of - Create new .xml Document = 01Mountinstallwim.xml
    ------------------------------------------------------------------------------------------------------------------
    These 13 .xml files I have created and named them so,
    01Mountinstallwim
    02UnmountinstallwimCommit
    03UnmountinstallwimDiscard
    04DisplayinstallwimInfo
    05ExportWim10ProIndex#6
    06IntegrateUpdates
    07IntegrateDrivers
    08Compressinstallwim
    09Splitinstallwim
    10DisplaybootwimInfo
    11MountbootwimIndex#1
    12MountbootwimIndex#2
    13UnmountbootwimCommit
    14UnmountbootwimDiscard
    15IntergrateDriversIntobootwimIndex#1andIndex#2
    16LoadREGHive
    17UnloadREGHive
    So far on my project I have 13 buttons amending one file from 1 to 13.
    Also I have one button which has the above script 13 times with just the file name different, for each .xml file.

    All these buttons work perfectly and do exactly what I want.

    Now I just know you clever folk on here would know how to script a "loop" so I would have to have 13 buttons or even one button with the script repeating 13 times.

    I just don't know enough to be able to do this so I am asking for a bit of help and pointing in the right direction.

    Hoping somebody can give me an example of how to obtain file names of multiple .xml files, or .txt files.

    Hope this makes sense. Look forward to reading some replies..

    cheers..

    Just to add. These .xml files I wish the "Task Scheduler" to import all all of my making. I have taken the time to create the scheduled tasks and export them to work within my DISM folder structure. Those using DISM commands may recognise the naming.
    I am automating the procedure of getting the PC's user name details and SID details so when I do a fresh Windows install I can quickly and easily import my .xml files and have my DISM scripts up and running. If you know what I mean.

  • #2
    Just noticed from copying my script to pasting my script gaps have appeared.. Don't know why..

    My script is working fine..

    Comment

    Working...
    X
    😀
    🥰
    🤢
    😎
    😡
    👍
    👎