header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
In your opinion, What is the best/cleanest way to start an invisible script (-WindowStyle Hidden)
Last Post 30 Sep 2009 07:10 PM by PowerShell Jedi. 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Not Resolved
PowerShell JediUser is Offline
Basic Member
Basic Member
Posts:410
Avatar

--
30 Sep 2009 01:34 PM
    Today, I created a script using Powershell 2 on XP (WMF)



    The best way I could find to make it silent was to do the following...



    -----------

    1.) Create a .bat file that kicks off the Powershell script using the following line...

    powershell.exe -WindowStyle Hidden -noprofile -Noninteractive -command "& 'C:\Script.ps1' "



    2.) Create a shortcut to the .bat file that opens it minimized.



    3.) Next, I entered the path to the shortcut into the HKLM\..\Run Folder of the registry to have it start automatically when a user logs on (I didn't want to put it in startup).

    -------------



    The problem I run into is (and maybe I'm being nitpicky here). The "script.bat" shows on the Start bar for 20 to 30 seconds when the script is kicked off during system logon and this whole processes of running a shortcut to run a minimized .bat file to run a .ps1 seems like a bit much.
    PoSH is a Automation Technology surfaced as a scripting language, not a "spice" ;-)
    Marco Shaw (MVP)User is Offline
    Veteran Member
    Veteran Member
    Posts:1647
    Avatar

    --
    30 Sep 2009 05:23 PM
    Why do you need to wrap it into a .bat anyways?
    Marco

    *Microsoft MVP - Windows PowerShell
    https://mvp.support.microsoft.com/profile/Marco.Shaw
    *Co-Author - Sams Windows PowerShell Unleashed 2nd Edition
    *Blog - http://marcoshaw.blogspot.com
    PowerShell JediUser is Offline
    Basic Member
    Basic Member
    Posts:410
    Avatar

    --
    30 Sep 2009 07:10 PM
    I guess that's the way I learned to do it. but I think I see what your getting at. I should just put the powershell.exe line in a custom shortcut or directly into the Registry. I think I read somewhere that I had to use a .bat file for task sceduler and have been doing it ever since. Boy do I feel silly. 8-)
    PoSH is a Automation Technology surfaced as a scripting language, not a "spice" ;-)
    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