The short: I am trying to make a 1 line command script that sets and uses a variable. Right now I came up with:
cmd /C "set var=127.0.0.1 & echo %var%"
I would expect it to output 127.0.0.1, but instead it prints %var%.
The long: I am using keepass as a password manager and trying to make it automatically launch a RDP session for me. I put the following in the URL:
cmd://cmd /C "cmdkey /generic:TERMSRV/127.0.0.1 /user:{USERNAME} /pass:{PASSWORD} & mstsc.exe /v:127.0.0.1 & cmdkey /delete:TERMSRV/127.0.0.1"
This works, but if I need to update the ipaddress, I have to touch 3 places instead of just 1. I tried changing it to the following, but it didn't work:
cmd://cmd /C "set sServer=127.0.0.1 & cmdkey /generic:TERMSRV/%sServer% /user:{USERNAME} /pass:{PASSWORD} & mstsc.exe /v:%sServer% & cmdkey /delete:TERMSRV/%sServer%"