header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Power Shell calling .exe from Windows Service
Last Post 29 Jun 2009 09:15 AM by CodeSlinger. 1 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
samkUser is Offline
New Member
New Member
Posts:1
Avatar

--
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
    CodeSlingerUser is Offline
    New Member
    New Member
    Posts:9
    Avatar

    --
    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.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer