• Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
  • Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

Scripted process to remove a file/folder before imaging

Scheduled Pinned Locked Moved
Feature Request
2
2
219
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D
    dashwell
    last edited by Mar 10, 2022, 2:39 PM

    Is there a way we can script the removal of a file or folder before the capturing of an image. Or, can it be scripted to be done after the image is deployed. Before the final reboot?

    G 1 Reply Last reply Mar 10, 2022, 3:11 PM Reply Quote 0
    • G
      george1421 Moderator @dashwell
      last edited by george1421 Mar 10, 2022, 9:12 AM Mar 10, 2022, 3:11 PM

      @dashwell Normally you would delete the file before capture in our source OS. But I know sometimes you just need to edit / remove one file from the target system.

      You can do what you want with a FOG post install script. I have a tutorial on how to inject drivers into a target windows system that you can use as the basis. Start by reading this: https://forums.fogproject.org/topic/11126/using-fog-postinstall-scripts-for-windows-driver-injection-2017-ed

      The only scripts you will need to start with is fog.custominstall

      In this section of the code you will need to change it for your purposes.

              debugPause
              . ${postdownpath}fog.copydrivers
              # . ${postdownpath}fog.updateunattend
              umount /ntfs
              ;;
      

      Lets change it to

              debugPause
              . ${postdownpath}fog.nukemyfile
              # . ${postdownpath}fog.updateunattend
              umount /ntfs
              ;;
      

      Now that above script will connect the C drive on the target computer disk to the /ntfs directory. The thing you have to remember is the FOG Post install script runs under linux and not a windows batch file. So there are some pain points you must remember. The first is the directory paths are forward slash ( / ) and not a backslash ( \ ). Second linux is case sensitive. So lets say you want to edit the unattend.xml file you would reference that file as /ntfs/Windows/Panther/Unattend.xml Note the path and case matching.

      So now you will need to create a file called fog.nukemyfile in the /images/postdownloadscripts directory on the fog server. Hint: If you first create the file on a windows box use notepad++ not windows notepad. You will save some headaches later.

      In that fog.nukemyfile file put the following.

      #!/bin/bash
      
      rm "/ntfs/apps/broadcom/config.ini"
      
      

      Assuming you wanted to remove the config.ini file in c:\apps\broadcom directory.

      The last bit from the tutorial you will need to hook the fog.custominstall script into the fog.postdownload script as mentioned.

      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      1 / 1
      • First post
        2/2
        Last post

      205

      Online

      12.0k

      Users

      17.3k

      Topics

      155.2k

      Posts
      Copyright © 2012-2024 FOG Project