![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Scheduling powershell.exe Scheduling ... Powershell.exe -PSConsoleFile q.psc1 -NonInteractive -NoProfile -command .... brings up the interactive window. I dont want the interactive window in the desktop. I tried set-executionpolicy unrestrictd but that does not seem to make any difference . I am wondering if any one has hit an issue like this one. I am really stuck here . Any information will greatly helpful .... |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Scheduling powershell.exe powershell.exe -? reveals the following parameter -Noninteractive Does not present an interactive prompt to the user. haven't played with it myself yet, but enjoy Karl |
My System Specs![]() |
| | #3 (permalink) |
| Guest | RE: Scheduling powershell.exe Unfortunately, -NonInteractive does not seem to mean "don't show the window at all". Andrew Webb |
My System Specs![]() |
| | #4 (permalink) |
| Guest | RE: Scheduling powershell.exe Even this doesn't manage to *not* show the window... using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Diagnostics; using System.Threading; namespace WindowsApplication21 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Thread thread = new Thread (new ThreadStart (Start)); thread.IsBackground = true; thread.Start (); } public void Start () { try { Process process = new Process (); process.StartInfo.FileName = "powershell.exe"; process.StartInfo.Arguments = "-Noninteractive -NoLogo -command \"cd 'C:\\Documents and Settings\\Andrew Webb\\Desktop'; ./test.ps1\""; process.StartInfo.CreateNoWindow = true; process.Start (); } catch (Exception ex) { Debug.WriteLine (ex.Message); } } } } |
My System Specs![]() |
| | #5 (permalink) |
| Guest | RE: Scheduling powershell.exe Consider writing a program with no window that hosts a PowerShell runspace; execute your commands/script in that runspace. Lee Holmes has an example of how to do this on his PowerShell blog: http://www.leeholmes.com/blog/MSHLog...tionality.aspx This will *definitely* not show any window. Andrew Webb |
My System Specs![]() |
| | #6 (permalink) |
| Guest | RE: Scheduling powershell.exe I got it! Finally! The following C# code shows how:- Process process = new Process (); process.StartInfo.FileName = "powershell.exe"; process.StartInfo.Arguments = "-Noninteractive -NoLogo -command \"cd 'C:\\Documents and Settings\\Andrew Webb\\Desktop'; ./test.ps1\""; process.StartInfo.CreateNoWindow = true; process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; process.Start (); Andrew Webb |
My System Specs![]() |
| | #7 (permalink) |
| Guest | RE: Scheduling powershell.exe For the ultimate solution, see my new post: "PSScriptRunner - run a PS script with no window flashing on screen". Andrew Webb |
My System Specs![]() |
| | #8 (permalink) |
| Guest | RE: Scheduling powershell.exe Andrew... I ll check your solution yet ... I think it should do it ... BTW ..Is there any other way to do accomplish this ... I ave developed a couple of cmdlets and it will be scheduled using NT scheduler ..thanks "Andrew Webb" wrote: > For the ultimate solution, see my new post: "PSScriptRunner - run a PS script > with no window flashing on screen". > > Andrew Webb |
My System Specs![]() |
| | #9 (permalink) |
| Guest | RE: Scheduling powershell.exe > BTW ..Is there any other way to do accomplish this ... In your scheduled task, you are launching an executable (PowerShell.exe) - but as you've seen, this brings up a window that is on screen for as long as the script takes to execute. And as you've also seen, no command-line switch makes the window be hidden. With my solution:- http://www.databatcher.com/freestuff/PSScriptRunner.zip you are also running an executable, but my exe a) creates no window for itself and b) forks PowerShell such that its window is hidden. Very basic stuff. Of course the command line arguments that you pass to my exe are passed along to PowerShell. So... is there another way to accomplish the same thing? Not that I've found. And even if there is, I think my way is the simplest. If you're a programmer you're free to take my technique and build it into a program of your own making of course. Andrew |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| window scheduling | sam dk | Vista General | 0 | 04-25-2008 08:55 AM |
| scheduling script | Ben Christian | PowerShell | 5 | 04-09-2008 12:12 PM |
| scheduling a powershell script | oldtechie | PowerShell | 12 | 01-22-2008 07:40 PM |
| Scheduling Non Interactive powershell job | =?Utf-8?B?Qk0=?= | PowerShell | 2 | 09-26-2006 06:54 PM |
| Scheduling running of PowerShell Scripts | Andrew Watt [MVP] | PowerShell | 1 | 07-21-2006 05:01 PM |