Sendkeys is programmed to interact with the active user's interface. So if your computer is locked, it will not do anything because the interface is locked.
Depending on the CLI, it may have parameters to login on initialization.
Given the test.bat file:
CD C:\Program Files\example\exampleclidirectory
set user=username
set pswd=password
cmdline.exe -user %user% -password %pswd%
If parameters are not an option, try to use SendMessage/PostMessage and FindWindow instead of Sendkeys. This should be available in C# or VB. But I'd suggest C#.
Here's some resources on that:
http://www.codingvision.net/miscellaneous/c-send-text-to-notepad
I can't understand how to use SendMessage or PostMessage calls
And that should give you some method of entering in the data you need to get the program rolling.