1

i wrote a posh script running in a windows service. From specific action on the computer, I need to display a popup window warning the user.

$popupMsg = @" message "@   
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[System.Windows.Forms.MessageBox]::Show($user+ $popupMsg,"Remote Connection Information","OK","Warning")

When I run this script from PowerGui, the popup displays fine, but when i run the windows service that runs this script, the popup won't show up. What's wrong in this ? Thanks people !

1
  • Services are by definition non-interactive. To display a dialog from one, you would have to invoke a foreground script, with the above. Commented Sep 6, 2012 at 7:59

2 Answers 2

1

Try setting "Allow service to interact with desktop" in the Service settings:

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

I cannot do that as I'm using the 'This account' option to specify an applicative logon wich is allowed to run the service
1

What version of Windows do you wish to support? Session 0 Isolation will prevent you from showing any kind of GUI on a user's desktop on Vista and beyond.

2 Comments

unfortunately I'm using essentially Win 7 and just a little bit of win xp... So I guess there's no solution for me then... What about asking my service to launch a .exe file when timer tick ? Would that do the trick ?
Launching an exe in the user's session is an option but may be overkill. If you can figure out the ID of the user's session, you can use WTSSendMessage to display a message box there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.