Jump to content

Extracting variable subfolder name from path

Go to solution Solved by Subz,

Recommended Posts

Apologies if this is answered elsewhere, I have searched the menu.

I am using the Chrome UDF without issues, but have noticed that sometimes Chrome randomly starts the Software Reporter Tool which is a resource-hog.  I address this currently by removing permissions from the .exe file but when Chrome updates itself these are restored.  One option is to delete the .exe altogether which I thought I could achieve using FileExists and FileDelete, but the problem is the path where the tool is located has a variable element.

For this computer the path is C:\Users\Dell\AppData\Local\Google\Chrome\User Data\SwReporter\102.286.200\software_reporter_tool.exe

The '102.286.200' changes from time to time, so what I'd like to be able to do is obtain that part of the path using a script so I can assemble the delete commands properly.

Any help much appreciated


Link to comment
Share on other sites

StringInStr with StringMid can perform this. SRER can do it quite easily.  

#include <Constants.au3>

Local $sURL = "C:\Users\Dell\AppData\Local\Google\Chrome\User Data\SwReporter\102.286.200\software_reporter_tool.exe"
Local $sSub = StringRegExpReplace($sURL, ".*\\SwReporter\\(.*)\\.*", "$1")
MsgBox($MB_SYSTEMMODAL, "Test", $sSub)


Edited by Nine
Link to comment
Share on other sites

  • Solution

Alternatively you could use _FileListToArrayRec to find all instances of software_reporter_tool.exe and delete, for example:

#include <File.au3>
Global $g_aSWReporter = _FileListToArrayRec(@LocalAppDataDir & "\Google\Chrome\User Data", "software_reporter_tool.exe", 1, 1, 0, 2)
If @error Then Exit
For $i = 1 To $g_aSWReporter[0]
;~ Uncomment below to delete instance
;~  FileDelete($g_aSWReporter[$i])
    ConsoleWrite($g_aSWReporter[$i] & @CRLF)


Link to comment
Share on other sites

in addition to the solutions provided already I'd like to mention to create a SYSTEM task, that will cleanup all occurences in all local user profiles, running e.g. at 08:00 AM every day:



$Daily="täglich" ; modify to your localization's string for "daily" --> schtasks /create /?
$Highest="höchste" ; modify to your localization's string for "higest"

$Params = '/create /ru "SYSTEM" /tn "Delete Chrome Software Reporter from all user profiles"  /tr "C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -command &{gci c:\users\software_reporter_tool.exe -r -file -force -ea si | remove-item -force}" /sc ' & $Daily & ' /st ' & $Time24 & ' /HRESULT /RL ' & $Highest & ' /f'


with the additional parameter " /s OtherPChostName" you can push this as a scheduled task to remote PCs as well (admin rights required on the remote system, of course)

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...