Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm working on trying to find a way to get our windows machines to report to a webpage with information about it's MAC address, computer name, currently logged in user, and ip address. I wrote a powershell script and set it up as a scheduled task. It works great but there is a window that appears every time the script runs. Is there a way to not show the window. I've tried running with "-noninteractive", "-nologo", "-windowstyle hidden", "-noprofile", all to no avail. This is what I use to run it.

"powershell.exe -noninteractive -nologo -windowstyle hidden -command "C:\Users\%LogonUser%\Scripts\CallHome.ps1"

share|improve this question

4 Answers 4

I think of two possibilities which you can try:

  1. Create a service user which has the user right to run batch jobs and log on as a service, schedule the task as that user wether it is logged on or not. This works and I use it frequently.

  2. Use the start-process cmdlet. I believe it is capable of doing what you want but can't test myself right now (on iphone).

share|improve this answer
1  
I like that you suggested a user with limited permissions instead of just running the scheduled task as SYSTEM. –  Ryan Ries Nov 14 '13 at 17:19

Have you tried running it like this:

start "" %systemroot%\System32\windowspowerShell\v1.0\powershell.exe -exec bypass -noprofile -windowstyle hidden -file "C:\Users\%LogonUser%\Scripts\CallHome.ps1" 
share|improve this answer
up vote 0 down vote accepted

I ended up moving the script to a folder in the C: root and then running the script as the SYSTEM user. It grabs the currently logged on users when it runs so I no longer need it to run as those users. Been working great since I got it working and my inventory is building itself.

share|improve this answer

You can also check Run whether user is logged on or not on the General tab of the task properties. In this mode the program is started hidden.

A problem could be that you have to specify the user's password when setting up the task.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.