Menu

Automatic image saving at regular intervals?

MeMe
2021-01-29
2021-11-07
  • MeMe

    MeMe - 2021-01-29

    I am using the program to run Firefox entirely from an 2GB exFAT ramdisk & it works great apart from one issue.

    I was using SoftPerfect RAM Disk before this and it has an option to allow you to set a time period where the image will be automatically synchronised. I can't seem to find an equivalent option in ImDisk.

    The image does automatically synchronise upon system shutdown / reboot but nothing in-between. The issue with that is that if i have a system crash i will lose any changes that are made in the browser in that time.

    Is there any way to force the image to be automatically synchronised at regular intervals?

    Thanks.

     
  • v77

    v77 - 2021-01-29

    Your system is not supposed to crash. :)
    That could be a feature to add...
    For now, you can create a scheduled task with a command such as
    "C:\Program Files\ImDisk\ImDiskTk-svc" SYNC
    of course with administrative privileges.

     
  • MeMe

    MeMe - 2021-01-29

    Thank your for replying so quickly, i will give that a go.

    I wonder though, is it possible to setup a scheduled task that will only perform the sync action when my browser (firefox.exe) is open? If the browser is closed then it will not be syncing any changes and will just wear on the SSD needlessly.

    Thanks again.

     
  • v77

    v77 - 2021-01-29

    You could try to call a batch file in the scheduled task with a command such as
    tasklist /fi "imagename eq firefox.exe"|findstr /c:firefox.exe && echo hello

    As you can see if you test it in a command prompt, "hello" is displayed only if Firefox is open.
    You can then replace "echo hello" with the command given above, and that should do the trick.

     
  • MeMe

    MeMe - 2021-01-29

    Fantastic, thank you again. And yes, i do think that is a feature well worth adding.

     
  • Lupin

    Lupin - 2021-11-07

    Yes, that's a feature I'd also find nice to have. For the exact same reason actually. I want my Firefox profile to be in RAM but be synced to disk regularly. Yes, my system shouldn't crash (and I can't remember when it last did), and I shouldn't have a power outage either (can't remember when that last happened as well), but I also almost never shut my computer down. I always send it into sleep mode which means my computer won't see a real reboot for weeks or even month. If the sync would only happen on shutdown, I would lose a lot of "history" (not just talking about URLs here, but also login data, changed FF settings aso.)

     
  • Lupin

    Lupin - 2021-11-07

    I went down the rabbit hole and checked what can be done with the windows task scheduler and custom triggers. For me it is fine to only sync when Firefox is closed.

    I first enabled "audit process termination" in Windows. You can do that in the group policy editor (gpedit.msc) under "Computer Configuration -> Windows Settings -> Security Settings -> Advanced Audit Policy Configuration -> Audit Policies" (I have the German Windows 10 version, so I can't tell you for sure that's correct). This creates log entries in Windows' security log with event ID 4689.

    I then created a task that listens for those events and checks if it was a firefox process that ended. This is the custom XML-trigger for it:

    <QueryList>
        <Query Id="0" Path="Security">
            <Select Path="Security">
                *[System[Provider[@Name='Microsoft-Windows-Security-Auditing']]]
                and
                *[System[EventID=4689]]
                and
                *[EventData[Data[@Name='ProcessName'] and Data='C:\Anwendungen\Netzwerk\Browser\firefox_unbranded\firefox.exe']]
            </Select>
        </Query>
    </QueryList>
    

    Be sure to enter the full path to firefox.exe. The scheduler queries don't support substring matching to make the trigger universal for everyone.

    The task calls a batch file containing just this line:

    tasklist /fi "imagename eq firefox.exe" | findstr /i /c:firefox.exe > nul 2>&1 || "C:\Anwendungen\System\ImDisk\ImDiskTk-svc.exe" SYNC
    

    It lists the running "firefox.exe" processes. Because tasklist returns something like "no task found", if there is no firefox.exe, we still have to check for "firefox.exe" with findstr. The double pipe "||" makes the ImDisk sync command run only when there were no "firefox.exe" lines found, i.e. Firefox is completely closed and not the event wasn't just just one of its sub-processes for tabs ending.

    Now I just need to find a way to use the ramdisk as usual for everything else, but somehow inject my firefox profile directory to be the image to be loaded.

    Btw. to run the batch file without a short flash of a console window I use Nirsoft's nircmd ("path\to\nircmd.exe" exec hide "batchfile.bat").

     

    Last edit: Lupin 2021-11-07

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.