Register
: :
Login
Home
News
Forums
Scripts
User Groups
Resources
About
Forums
Search
Members
Unanswered
Active Topics
Forums
>
PowerShell Development
>
Hosting the Shell
Power Shell calling .exe from Windows Service
Last Post 29 Jun 2009 09:15 AM by
CodeSlinger
. 1 Replies.
Sort:
Oldest First
Most Recent First
Prev
Next
You are not authorized to post a reply.
Author
Messages
samk
New Member
Posts:1
02 Jun 2009 04:32 AM
Greetings,
I have a Windows Service hosting a powershell "server" which executes any cmdlets or ps1 files. I call the service from a Perl socket client:
perl client.pl "powershell.exe -PSConsoleFile 'C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1' -Command 'c:\scripts\auto\pstest.ps1'"
Here is pstest.ps1:
c:\scripts\auto\updatead.exe
$status = $lastexitcode
$force = 1
if ( $status -eq 0 ) { "Nothing to do" }
elseif ( $status -le 500 ) {
"Processing upto 500 results ($status to be exact)..."
c:\dir\automate\update.ps1
}
elseif ( $force ) { "Forcing changes" }
else { "Too many changes - use -force" }
The updatead.exe is a C# program which writes update.ps1 with user accounts that need updating. Calling update.ps1 by itself doesn't cause any problem, but UPDATEAD.EXE is is not executed for some reason.
For testing I created a HelloWorld.exe (tried both x86 and x64) and it works fine if I replace updatedad.exe with HelloWorld.exe. There is something wrong with updated.exe but my concern is why PowerShell is not returning the output (whatever it maybe) as it returns of HelloWorld.exe? Any Ideas? Will greatly apprecaite any help.
Regards,
msk
CodeSlinger
New Member
Posts:9
29 Jun 2009 09:15 AM
If the above is just an example, and the real path maybe has a blank in it, you could try this:
& 'c:\scripts\auto\updatead.exe'
You are not authorized to post a reply.
Using PowerShell
--General PowerShell
--Books, Tools, and Videos
--Exchange Server
--Active Directory
--System Center Family
--Non-Microsoft Products
--SharePoint
--SQL Server
--Working with .NET
--Peer Review
--Testing, Testing...
PowerShell Development
--Cmdlet Development
--PSDrive Provider Development
--Hosting the Shell
Looking Ahead
--Using PowerShell v2.0
--Developing for PowerShell v2.0
PowerShellCommunity.org
--Community Announcements and Assistance
--Completely Unrelated
--User Groups
--Community Business
----Suggestion Box
Forums
>
PowerShell Development
>
Hosting the Shell
Active Forums 4.3
Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2