Unable to find the file path and it's return anything

I am trying to find the file “VC_redist.x86” under the folder "C:\ProgramData\Package Cache" and store the file path .

It’s not working and it’s not return any value. Need assistance.

delete __createfile
parameter “folderPath” = "C:\ProgramData\Package Cache"
parameter “searchString” = “VC_redist.x86”

createfile until __EOF
{concatenation “%0d%0a” of (pathname of it) of files whose (name of it as lowercase contains (parameter “searchString”)) of folder (parameter “folderPath”)}
__EOF

move __createfile “C:\file_paths.txt”

At a glance, I’d say that no result will ever be returned because you’re comparing a string with uppercase letters “VC_redist.x86” with another string coerced to be lowercase.

Maybe put “as lowercase” after the search string?

Try this for your relevance

You’re looking for the file in the folder C:\ProgramData\Package Cache\ but that location only contains folders and the file you’re looking for is inside one of those folders

`(pathname of it) of files whose (name of it as lowercase contains (parameter “searchString”) as lowercase ) of folders of folder (parameter “folderPath”)

parameter "folderPath" = "C:\ProgramData\Package Cache"
parameter "searchString" = "VC_redist.x86"

createfile until __EOF
{concatenation "%0d%0a" of (pathname of it) of files whose (name of it as lowercase contains (parameter "searchString") as lowercase ) of folders of folder (parameter "folderPath")}
__EOF

move __createfile “C:\Temp\file_paths.txt”

Unable to move or copy the result … It’s failing

Retry error, attempt 9 failed for MoveFile (C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData\opsite334__createfile ,C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData\opsite334\“C:\Temp\file_paths.txt”)
At 12:00:04 -0600 - actionsite (http://bfroot.us.com:52311/cgi-bin/bfgather.exe/actionsite)
Command failed (Move of ‘C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData\opsite334__createfile’ to ‘C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData\opsite334\“C:\Temp\file_paths.txt”’ failed (123 - File error “class FileMoveError” on “C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData\opsite334__createfile” and “C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData\opsite334\“C:\Temp\file_paths.txt”” : “Windows Error 0x7b%: The filename, directory name, or volume label syntax is incorrect.”)) move __createfile “C:\Temp\file_paths.txt” (action:2313374)
At 12:00:04 -0600 -

Does C:\Temp exist? In your original code, you just had C:\file_paths.txt which worked for me.

If I change it to C:\Temp\file_paths.txt then it fails with a file move error because C:\Temp doesn’t exist in my environment

Here’s how I would do it to make sure your paths exist and you remove the file before replacing it, if it exists

parameter "folderPath" = "C:\ProgramData\Package Cache"
parameter "searchString" = "VC_redist.x86"
parameter "resultFolder" = "C:\Temp"
parameter "resultFile" = "file_paths.txt"

if { not exists folder ( parameter "resultFolder" ) }
	folder create { ( parameter "resultFolder" ) }
endif

if { exists "__createfile" }
	delete "__createfile"
endif

createfile until __EOF
{concatenation "%0d%0a" of (pathname of it) of files whose (name of it as lowercase contains (parameter "searchString") as lowercase ) of folders of folder (parameter "folderPath")}
__EOF

if { exists file ( ( parameter "resultFolder" ) & "\" & ( parameter "resultFile" ) ) }
	delete { ( parameter "resultFolder" ) & "\" & ( parameter "resultFile" ) }
endif

move __createfile { ( parameter "resultFolder" ) & "\" & ( parameter "resultFile" ) }

2 Likes

It’s working as expected. Thanks a lot :wave:

1 Like

Glad to help. Hopefully you can use this as a template for other things like this.

Yes. It was helpful.

I have changed the code as follows:

parameter “folderPath” = “C:\ProgramData\Package Cache”
parameter “searchString” = “VC_redist.x86”
parameter “resultFolder” = “C:\Temp”
parameter “resultFile” = “file_paths.txt”

if { not exists folder ( parameter “resultFolder” ) }
folder create { ( parameter “resultFolder” ) }
endif

if { exists “__createfile” }
delete “__createfile”
endif

createfile until __EOF
{concatenation “%0d%0a” of (pathname of it) of files whose (name of it as lowercase contains (parameter “searchString”) as lowercase ) of folders of folder (parameter “folderPath”)}
__EOF

if { exists file ( ( parameter “resultFolder” ) & "" & ( parameter “resultFile” ) ) }
delete { ( parameter “resultFolder” ) & "" & ( parameter “resultFile” ) }
endif

move __createfile { ( parameter “resultFolder” ) & "" & ( parameter “resultFile” ) }

action uses wow64 redirection false
if {exists file “C:\Temp\file_paths.txt”}
parameter “vcRedistPath” = “{line 1 of file “C:\Temp\file_paths.txt”}”
waithidden start /B cmd.exe /C "{parameter “vcRedistPath”} /uninstall /passive /norestart >NUL 2>&1
else
appendfile “search_result.txt not found”
endif

delete __appendfile
appendfile @echo off
appendfile :loop
appendfile wmic product get name | findstr /i “Microsoft Visual C++ 2013 Redistributable”
appendfile if %errorlevel%==0 (
appendfile timeout /t 60
appendfile goto loop
appendfile )
appendfile exit /b 0
move __appendfile check_package.bat

waithidden cmd.exe /c check_package.bat

I have created the 2 logics now.

  1. Run the uninstallation in the background ( marked bold above )
  2. Created the logic for verfying the uninstallation ( Marked bold above )

Instead of bat file, do we have option to minimize the code using bigfix action script for checking the uninstallation process?

Note: cmd.exe is keeps on running even after uninstall… Hence I have created the above 2 logics and running cmd.exe in the background.
After compilition of uninstallation , I need to kill the cmd.exe task process…

Kindly help me here, thanks .

You need to figure out why your cmd process is not exiting and probably fix that part first.

Thanks for your response Jason.

To be honest, I have lot of trick in uninstallation of Visual C++.

Working on it Jason.