I learned about the
call command in Windows recently.
Some context – was trying to run a command via HPSA at a customer, but kept getting an error that the program was not a recognized internal or external command.
Then one of the guys I worked with suggested adding a “call” to the front of my script. That worked like a champ. Here’s why.
When the HPSA Agent on a Managed Server receives a script to run from the Core, it runs it in a headless terminal session. This means that while environment variables (eg
%ProgramFiles%) expand properly, if the first part of the command is NOT a built-in from cmd.exe, it won’t execute. Unlike *nix which is designed to run most things headless, Windows never was (and isn’t still as of Win2k8R2).
The built-in command ‘
call‘ forks the next command to a full session (albeit still headless), and enables
cmd.exe to run it properly.
Now you know.