Deploy Windows 'Unattended' software through SSH

After we started using Unattended which I have mentioned in the first post on this, it has developed very well. New software/drivers are easily added and it's working very well overall. There has been one annoying flaw, however. It was not possible to deploy software to already deployed workstations without visiting the workstation or logging in through VNC and interacting with the desktop. It looks like I managed to overcome this issue.

Unattended automatically installs CYGWIN sshd when it installs a workstation and I have made it put in a management key which we use for passwordless logins to our workstations. We now use the following script from Linux:

win-install

#!/bin/sh
ssh root@$1 "net use z: \\\\\\\\<unattended server>\\\\install '$2' /user:<DOMAIN>\\\\install; /cygdrive/z/scripts/install.bat $3; net use z: /d /y"

which is called like

win-install [workstation] [password] [batchfile]

This connects to the workstation and maps the Z: drive using the dedicated 'install' user and the password we give it and then runs the unattended batch file by first preparing the environment in the install.bat which looks like this:

install.bat

set Z=Z:
set PATH=%Z%\bin;%PATH%
set WINLANG=ENU
CALL %Z%\scripts\%1
todo.pl --go

This installs software even if nobody is logged in to the workstation. Admittedly this could fail for some software, though I haven't seen a problem yet. Also this only works with scripts which don't have to reboot the machine. It is possible to extend it to scripts which need reboots by using the autolog.pl, but that would need an extra local Administrator password. Obviously before running such scripts one needs to check if anybody is using the workstation at that moment.

Please note that passing the password on the command line is not secure, so it's better to put it into an environment variable, but to connect the drive in Windows, we need to pass it as an argument eventually, so it's best to use a very limited account.