Batch file not found after downloading

I have a very simple batch file that changes the desktop background when the PC is locked and also copies a themepack file to the desktop. Used the software wizard to upload and create a package for distribution, but it is failing on the clients.

The SWD deployment results log shows this:
2015_10_29 17:50:02.52
Action ID: 3213
Command: "background.bat"
The system cannot find the file specified.
The system cannot find the file specified.

Even though the console shows the files downloaded, the client can’t seem to find the batch file.

and the content of the batch file is this:

@echo off
copy /Y %~dp0\backgrounddefault.jpg C:\Windows\System32\oobe\info\backgrounds
copy /Y %~dp0\TGCSThemePack.themepack %ALLUSERSPROFILE%\Desktop\

Any ideas?

Can you post your action script please?

Sure

// ---------------------------------------------EDITING INSTRUCTIONS---------------------------------------------------------------------
// When editing this task through the Manage Software Distribution Packages dashboard, you will have the option to preserve any custom edits you make to this action.
// If you select the option to preserve custom edits, only areas bound by the comment markers ā€˜Preparation Marker’, ā€˜Command Marker’ and ā€˜Closing Marker’ are updated.
// To ensure that all your custom Action Script changes can be preserved, only make changes to areas that are not bound by the comment markers.
// Removing the comment markers may result in the Action Script not updating correctly during the next edit.
// See KB Article swg21668807 (http://www-01.ibm.com/support/docview.wss?uid=swg21668807) for more information.
// --------------------------------------------------------------------------------------------------------------------------------------

//**Begin Preparation Marker
// Download all specified files
begin prefetch block
add prefetch item name=E095B08CCFA3D9E9451650A3D0762D940394BCAA sha1=e095b08ccfa3d9e9451650a3d0762d940394bcaa size=165 url=SWDProtocol://127.0.0.1:52311/Uploads/E095B08CCFA3D9E9451650A3D0762D940394BCAA/background.bat.bfswd sha256=ddb11c6f31ba73a13e60f1aef232a4e63314758c6a4ca00e2b2e64c3f29ffa8e
add prefetch item name=052045A33E7F6A6998ADC8D216DFEFF8B920C114 sha1=052045a33e7f6a6998adc8d216dfeff8b920c114 size=179148 url=SWDProtocol://127.0.0.1:52311/Uploads/052045A33E7F6A6998ADC8D216DFEFF8B920C114/backgrounddefault.jpg.bfswd sha256=66b4b2f9b4e4c0a784a216925e93405b31b6a8c73cd08dbfb697e9dbd8f417c6
add prefetch item name=E32D952252D34FFFB704BDC2EA31150229C499E8 sha1=e32d952252d34fffb704bdc2ea31150229c499e8 size=6669684 url=SWDProtocol://127.0.0.1:52311/Uploads/E32D952252D34FFFB704BDC2EA31150229C499E8/TGCSThemePack.themepack.bfswd sha256=9f6b6a13eaf1f09a6ee887313e039f36ef782986ff3e73cd1cb7a3482541d6ff
end prefetch block

// All SWD files will go into a folder in the clients __BESData folder. This folder gets cleared on every restart.
parameter ā€œbaseFolderā€ = ā€œ__Download/ā€
// Move files into subfolders and unescape file names
move ā€œ__Download/E095B08CCFA3D9E9451650A3D0762D940394BCAAā€ "{parameter ā€œbaseFolderā€}background.bat"
move ā€œ__Download/052045A33E7F6A6998ADC8D216DFEFF8B920C114ā€ "{parameter ā€œbaseFolderā€}backgrounddefault.jpg"
move ā€œ__Download/E32D952252D34FFFB704BDC2EA31150229C499E8ā€ ā€œ{parameter ā€œbaseFolderā€}TGCSThemePack.themepackā€

// Log setup
parameter ā€œmainSWDLogFolderā€ = "{parent folder of client folder of current site}/__Global/SWDDeployData"
folder create "{parameter ā€œmainSWDLogFolderā€}"
parameter ā€œlogFileā€ = ā€œSWD_DeploymentResults.logā€

//**End Preparation Marker
delete __createfile
parameter ā€œlogFolderā€ = ā€œ{parameter ā€œmainSWDLogFolderā€}ā€
// Run setup process
delete run.bat

// Use .bat to set working directory to packages root, for setup command.
createfile until end
@ECHO OFF
cd "{parameter ā€œbaseFolderā€}"
rem // See comments at the beginning of this action for an explanation of the comment markers.
set DATESTAMP=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%
set DATEANDTIME=%DATESTAMP% %time%
echo %DATEANDTIME% >> "{parameter ā€œlogFolderā€}/{parameter ā€œlogFileā€}"
echo Action ID: {id of active action} >> "{parameter ā€œlogFolderā€}/{parameter ā€œlogFileā€}"
rem //**Begin Command Marker
echo Command: ā€œbackground.batā€ >> "{parameter ā€œlogFolderā€}/{parameter ā€œlogFileā€}"
set errorlevel=
ā€œbackground.batā€ >> ā€œ{parameter ā€œlogFolderā€}/{parameter ā€œlogFileā€}ā€ 2>&1
set SWDExitCode=%errorlevel%
rem //**End Command Marker

echo Return code: %SWDExitCode% >> "{parameter ā€œlogFolderā€}/{parameter ā€œlogFileā€}"
echo. >> "{parameter ā€œlogFolderā€}/{parameter ā€œlogFileā€}"
exit %SWDExitCode%
end

move __createfile run.bat
// You will not be able to stop or take action on an applicable BigFix Client until your installer completes.
// So ensure no user input is required.
// If your package absolutely must interact with the user, replace ā€˜override wait’ with ā€˜override run’ and ā€˜wait’ with ā€˜run’.
override wait
hidden=true
completion=job
wait run.bat

//**Begin Closing Marker
// Get the return code of the previous action.
parameter ā€œreturnCodeā€ = ā€œ{exit code of action}ā€

// Task will now exit.
exit {parameter ā€œreturnCodeā€}
//**End Closing Marker

Welcome to the forums!

Let me know if this helps:

Edit: What I said in this reply is wrong – sorry

The background bat is not at the root of the folder of the action it is in a __Download folder. When the BigFix client starts an action it changes its working directory to the root of the folder corresponding to the custom site the action is coming from. In this case it is trying to run the batch file from:
C:\program files (x86)\…\bigfix client\__BESData\nameofyourcustomsite\background.bat

By default the software distribution dashboard puts all downloads into __Download:

So you need to change it so bigfix tries to run it from here:
C:\program files (x86)\…\bigfix client\_BESData\nameofyourcustomsite\_Download\background.bat

You can do that by modifying the actionscript from:

"background.bat" >> "{parameter "logFolder"}/{parameter "logFile"}" 2>&1

to

"__Download\background.bat" >> "{parameter "logFolder"}/{parameter "logFile"}" 2>&1

Just to be clear, do both of these lines need updating:

echo Command: ā€œ__Download\background.batā€ >> ā€œ{parameter ā€œlogFolderā€}/{parameter ā€œlogFileā€}ā€œ
set errorlevel=
ā€__Download\background.batā€ >> ā€œ{parameter ā€œlogFolderā€}/{parameter ā€œlogFileā€}ā€ 2>&1

And I do see the files in this directory like you mentioned:
C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData\actionsite__Download

But it is still failing.

My reply earlier was wrong…

The distribution dashboard adds this which makes it so you don’t need to add __Download:

So you don’t need to modify that at all

I think the, ā€œThe system cannot find the file specified.ā€ error is because the ā€œCopy /Yā€ is failing because it can’t find the file.

I think your copy might be failing due to the space in the path… you could try this:
copy /Y ā€œ%~dp0\backgrounddefault.jpgā€ C:\Windows\System32\oobe\info\backgrounds
copy /Y ā€œ%~dp0\TGCSThemePack.themepackā€ %ALLUSERSPROFILE%\Desktop\

If that doesn’t work I’d probably reupload the batch file with @echo off removed and I might add ā€œecho %~dp0ā€ to verify the path is correct.

Some progress, the themepack copied

2015_10_29 20:18:19.38
Action ID: 3221
Command: "background.bat"
The system cannot find the path specified.
0 file(s) copied.
1 file(s) copied.

I will play with the path for the first file.

1 Like

My guess would be that \oobe\info\backgrounds doesn’t exist by default in Windows 7 and you have to create the directory first before copying the file

1 Like

The directory does exist. The batch file is replacing a jpeg that is already in the directory. The batch file works without any issues outside of Bigfix.

The other thing that is probably occurring is wow6432 redirection.

Try adding this to the top of your action script…
action uses wow64 redirection false

I am not sure if this will work for the batch script but if it doesn’t we can change your action to copy the files using action script instead of a batch file.

1 Like

I have it working now. There must have been a hidden character in the name/path for the backgrounddefault.jpg. I re-typed, and also added the code for wow redirection.

Thanks!

1 Like