Answered by:
Using Powershell to create an exe to run as a service

Question
-
Can powershell be used to create an exe? I have a simple task of moving files from one drive to another, but we need an exe to run the task as a service to meet our monitoring and notification requirements. Any help or ideas would greatly be appreciated.Friday, November 30, 2012 10:51 PM
Answers
-
Not natively.
If you've got newer server OSs (2008R2) the new task scheduler lets you trigger a scheduled task base on logged events. Enabling object access auditing on the directories involved can be used to create logged events when new files are created, and a scheduled task can invoke the PS script to do the moves whenever the trigger events are logged.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
- Marked as answer by Yan Li_ Wednesday, December 5, 2012 7:37 AM
Friday, November 30, 2012 11:08 PM -
You can run powershell script as service without convert to an exe. - http://gfdsa.gfdsa.org/2009/11/29/start-powershell-script-as-service/
But if it's really needs covert to the exe format:
1) http://rkeithhill.wordpress.com/2010/09/21/make-ps1exewrapper/
- Marked as answer by zperryz Tuesday, December 4, 2012 10:56 PM
Saturday, December 1, 2012 6:55 PM
All replies
-
New-Service [-Name] <String> [-BinaryPathName] <String> [-Credential <PSCredential>]
[-DependsOn <String[]>] [-Description <String>] [-DisplayName <String>] [-StartupType
<ServiceStartMode>] [<CommonParameters>]This command is almost helpful, but it requires a exe.... I'd like to create one.
Friday, November 30, 2012 11:06 PM -
Not natively.
If you've got newer server OSs (2008R2) the new task scheduler lets you trigger a scheduled task base on logged events. Enabling object access auditing on the directories involved can be used to create logged events when new files are created, and a scheduled task can invoke the PS script to do the moves whenever the trigger events are logged.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
- Marked as answer by Yan Li_ Wednesday, December 5, 2012 7:37 AM
Friday, November 30, 2012 11:08 PM -
This sounds like a great option, but I'm not sure our monitoring system will notify us of failures which will be mandatory. I'll start with this.Saturday, December 1, 2012 12:01 AM
-
You can run powershell script as service without convert to an exe. - http://gfdsa.gfdsa.org/2009/11/29/start-powershell-script-as-service/
But if it's really needs covert to the exe format:
1) http://rkeithhill.wordpress.com/2010/09/21/make-ps1exewrapper/
- Marked as answer by zperryz Tuesday, December 4, 2012 10:56 PM
Saturday, December 1, 2012 6:55 PM