Register
: :
Login
Home
News
Forums
Scripts
User Groups
Resources
About
Forums
Search
Members
Unanswered
Active Topics
Forums
>
Looking Ahead
>
Using PowerShell v2.0
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.
Sort:
Oldest First
Most Recent First
Prev
Next
You are not authorized to post a reply.
Author
Messages
PowerShell Jedi
Basic Member
Posts:410
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)
Veteran Member
Posts:1647
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 Jedi
Basic Member
Posts:410
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.
Using PowerShell
--General PowerShell
--Books, Tools, and Videos
--Exchange Server
--Active Directory
--System Center Family
--Non-Microsoft Products
--SharePoint
--SQL Server
--Working with .NET
--Peer Review
--Testing, Testing...
PowerShell Development
--Cmdlet Development
--PSDrive Provider Development
--Hosting the Shell
Looking Ahead
--Using PowerShell v2.0
--Developing for PowerShell v2.0
PowerShellCommunity.org
--Community Announcements and Assistance
--Completely Unrelated
--User Groups
--Community Business
----Suggestion Box
Forums
>
Looking Ahead
>
Using PowerShell v2.0
Active Forums 4.3
Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2