2

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"

2

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

  • 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
0

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" 
0

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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