You are assuming, the error is related to permission to either the bat or the powershell file.
The error you get comes from a SP cmdlet, so you have successfully opened the bat file and successfully run the powershell script. Which then throws an error. UserB has not the apropriate rights to the farm. Hence the error:
...and that you have the appropriate permissions to access the database before trying again.
Compare the permissions from UserA and UserB on the farm and the database.
Or you could use a sledgehammer and log into UserA to run the following powershell script:
$db = Get-SPDatabase | Where {$_.Name -eq "SharePoint_ConfigDB"}
Add-SPShellAdmin "domain\UserB" -database $db