1

Our company builds a server-based C++ application, which can be installed by a Windows installer.

I would like to be able to remotely log into a brand new Windows server, and install that C++ application, along with a test suite, and do it from a Linux workstation. I would like to also automate this process with a Bash script which which I run from my Linux workstation.

With a Linux server, it is pretty straightforward to do. You start with a base configuration with sshd running, use scp to move a server-side bash script from the Linux client to the server, and then ssh into the Linux server from the Linux client and run the bash script.

But how do I do this when the client is Linux, but the server is Windows Server (e.g. 2k8r2)?

I am thinking of using Chef Solo for some of this, but I would still have to install Chef Solo. How would I do that remotely from a Linux Workstation.

Jay Godse
  • 111
  • 1
  • 5
  • Jay, I'm not sure I'm completely understanding your goal, but I'm wondering if Vagrant would help you. – JasonAzze Jun 09 '13 at 19:23
  • Will Vagrant let me write a script from a Linux workstation which logs into a remote Windows server (identified by IP address, user, password) download and install some software to the remote windows server, and start some services on the remote windows server. My interpretation of everything I have read about Vagrant says no, but I would love it if I was wrong. – Jay Godse Jun 10 '13 at 21:00
  • 1
    I wasn't sure if you were trying to create a system under which you could quickly create and destroy (manually or via automation) a test environment with certain characteristics (the C++ application and test suites.) That's where Vagrant would be strong. – JasonAzze Jun 11 '13 at 14:56

1 Answers1

2

You could try using winexe for that, it mimicks psexec from Linux. The source package (version 1.00) is actually using Samba source tree with that utility as an extra.

If your distro doesn't package that, you can compile it yourself. For version 1.00, unpack the tar file and from there:

$ cd source4
$ ./autogen.sh
$ ./configure 

(You'll need a proper build environment and Python 2.) The executable is located in the bin subdirectory after that.

The first time you run the tool, it will install (and start) a service on the remote Windows host. Subsequent calls are much faster.

Example use:

./bin/winexe //hostname -U domain\\account "cmd.exe /c dir c:\\"

I had to set a registry key to make it work on a Windows 7 target (requires reboot):

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system
Key: LocalAccountTokenFilterPolicy
DWORD value: 1

KB 942817 has some info on how to set that registry value when you deploy your targets. Note that this obviously has security implications.

Mat
  • 1,536
  • 1
  • 17
  • 21
  • Thanks. That solves half of my problem. The other question is how to get script files down to that machine so that I can run them to download and install other software. – Jay Godse Jun 10 '13 at 20:54
  • Set up a file share (via samba or another Window host). You can copy the files onto your target with `winexe` too (i.e. `winexe -U xx\\yyy "cmd /c copy \\\\server\\share\\foo c:\\temp`) – Mat Jun 11 '13 at 05:09
  • Would I set up this "file share" on my Linux box? How? (If I sound really ignorant, it is because I am). – Jay Godse Jun 11 '13 at 14:18
  • You could, using samba as I said above. There's lots of literature about it. – Mat Jun 11 '13 at 14:22