0

I am a PowerShell Noob so please forgive. I have a Windows ID on a Win 2008 R2 server that runs a dedicated Outlook VBA application. I have tried suggestions on how to get this userid to autologon should the server be restarted, but they have been unsuccessful. My thought this morning was if it would be possible to create a Cron task that runs on a time schedule, to check if the userid is logged on, and if not to actually force the logon.

Thank in advance for any assistance.

TheCleaner
  • 32,627
  • 26
  • 132
  • 191
  • What you are wanting could be done via Powershell, but I think you'd be better off using FireDaemon to create the service that would run in a separate session as that userID and run that VBA application. – TheCleaner Apr 13 '17 at 20:45

1 Answers1

2

If all you need to do is run Outlook as that user, I think TheCleaner's suggestion is probably the best option. You can do this from the command line, and then change the user that the service runs as from the services console. Check out the link below if you would like to do it without a third party app.

https://stackoverflow.com/questions/3582108/create-windows-service-from-executable

In response to comments, here is a starter for how to start with powershell. If this needs adjustment, please provide more context.

$hostname = "serverName"
$username = "CKnutson"
$processName = "outlook"

$session = New-PSSession $hostname 
Enter-PSSession $session

$processes = @()
$processes += Get-Process -IncludeUserName | Where-Object {$_.UserName -like "*$username" -and $_.Name -like "$processName"}

if ($processes.Count -eq 0) {
    Start-Process -FilePath "C:\proc.exe" -ArgumentList "-Silent" -LoadUserProfile
}

That should open a remote console to the server that you want to run outlook, check if there is a running process for that user, and then start it if needed.

Cory Knutson
  • 1,876
  • 13
  • 20
  • Thank you for the suggestions, but for reasons too detailed to go into now, I need a PowerShell solution that I can initiate as a cron task. Anyone that can help with the appropriate PowerShell script? – Kenneth Berg Apr 13 '17 at 21:33
  • I am pretty experienced with Powershell, but I fail to see what you are gaining by using powershell. If you are mentioning CRON, does that mean that you are wanting to scedule a task in a LINUX machine to check status? – Cory Knutson Apr 13 '17 at 21:39