Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting a Windows service in an interactive session

A colleague has a batch script program which needs to to run on a Windows Server in console mode, so that it has access to a Windows interactive session. The server is rebooted at regular intervals automatically (there's an unrelated closed-source application that runs on this machine that we have no control over). After a reboot he wants to automatically start a Windows interactive session and have this script run, plus the service needs to also have access to network resources (CIFS drives, in particular).

Here's what we've tried so far:

  1. Start as Windows service. This failed, since a Windows service can either have access to interactive session or to network resources, but never both.
  2. Used Microsoft management console to add the script to run at startup, however this did not work.
  3. Used an HKLM registry key to start to run this script, however it only gets started when we manually open a remote desktop session on the server.
  4. Creating a scheduled task. The program invoked did not have access to interactive windows session.

Any other suggestions? (Or maybe he missed something when he set up one of these suggestions?)

like image 530
Plutor Avatar asked May 22 '09 12:05

Plutor


1 Answers

In case "Interact with desktop" on the service is not enough (I have seen a handful of cases where it is not), you can combine it with AutoAdminLogon. Create three (or four for a domain) REG_SZ values under HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon:

  • DefaultUsername
  • DefaultPassword
  • DefaultDomain
  • AutoAdminLogon

AutoAdminLogon should be set to the string "1", the others are self-explanatory.

Obviously this has security issues big enough to fly Jupiter through.

like image 199
JimG Avatar answered Oct 09 '22 09:10

JimG