#since there are different user IDs from different PC hostnames, I replaced it with %userprofile%, to skip it and just only rename the test123 which is the last part.
To skip what? The userprofile environment variable contains text like C:\Users\UserName so the file name you are trying to process is C:\Users\C:\Users\UserName\Appdata\Local\test123. That won't work. It would use your username, not any user's name on the target pc's.
There is no ren.exe program for psexec to execute. "Ren" is a command prompt command. You would need to execute cmd.exe.
To find the individual test123 files, you look through each users folder. Powershell is your best option.
The code to do that is this.
Get-ChildItem c:\users | foreach {
$f = get-item ($_.fullname + '\Appdata\Local\test123') -ea SilentlyContinue
if ($f) {
'Renaming {0}' -f $f.fullname
Rename-Item $f -NewName 'Test123_old'
}
}
On a single line running against my test machine it would be this.
psexec \\test10 powershell.exe -command "Get-ChildItem c:\users | foreach { $f = get-item ($_.fullname + '\Appdata\Local\test123') -ea SilentlyContinue; if ($f) { 'Renaming {0}' -f $f.fullname; Rename-Item $f -NewName 'Test123_old'}}