header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Executable Script
Last Post 10 Nov 2007 12:04 PM by ambers. 11 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
valdezdjUser is Online
New Member
New Member
Posts:62

--
08 Nov 2007 08:28 PM  
I'm sorry if this is sounds basic but I haven't seen it in any of the Powershell books or blogs(I don't think) and nobody has submitted anything in awyhile so here it goes...

Is there any way to make a Powershell script just run by clicking on it? I know in VB you could create a script and it would be executable by just clicking on it. I know this isn't VB but its been buggin' me for awhile and I thougt I'd ask. Not really a necessity just curiosity.
Thanks for anyone responding.
bsonposhUser is Offline
Basic Member
Basic Member
Posts:392
Avatar

--
08 Nov 2007 11:48 PM  
You can change the .ps1 association to powershell... by default its notepad.

Brandon Shell
----------------
Microsoft Powershell MVP
https://mvp.support.microsoft.com/profile/Brandon
Blog: http://www.bsonposh.com
ambersUser is Offline
New Member
New Member
Posts:16
Avatar

--
09 Nov 2007 01:10 AM  

From personal experience I would highly recommend that you seriously consider not changing the association.

Other than general security risks, there is also the overwhelming possibility that you accidentally launch a script while trying to open a subfolder in that directory.  I told myself I wouldn't do this and about 2 weeks later I had a glitch on my workstation where a single click was interpreted as a double-click and wouldn't you know it that powershell worked perfectly at the absolute wrong time.

RosarioMUser is Offline
New Member
New Member
Posts:15
Avatar

--
09 Nov 2007 01:27 AM  
Anyone know a good way to compile a PoweShell script into an executable without the console window opening?

Admin Script Editor has the ability to compile a script into an EXE, but the console window still comes up. I know PoshConsole has a way to run hidden, but is there anything out there that combines the two?

Don Jones, how about PrimalScript?

I know you can build a c# or vb.net powershell hosted app, but I rather just work with a simple script and compile an exe with it to distribute...
ambersUser is Offline
New Member
New Member
Posts:16
Avatar

--
09 Nov 2007 01:58 AM  
I know PrimalScript 2007 Professional and Enterprise versions have a script packager that will do this.
ambersUser is Offline
New Member
New Member
Posts:16
Avatar

--
09 Nov 2007 01:59 AM  

Guess I missed part of that... I haven't tried it out to see if the window is hidden.

DonJUser is Offline
PowerShell MVP
Basic Member
Basic Member
Posts:134
Avatar

--
09 Nov 2007 04:25 PM  
Ya, PrimalScript will do it. It opens the console window as a hidden window. I think the dev team is going to have some future version of the packager actually just host PowerShell, but some complexities arise on that (from what little I understand) so for right now it's running the console.
- Don Jones
www.ConcentratedTech.com
Subscribe (RSS) or visit for weekly PowerShell tips and lessons
DonJUser is Offline
PowerShell MVP
Basic Member
Basic Member
Posts:134
Avatar

--
09 Nov 2007 04:27 PM  
Posted By valdezdj on 11/08/2007 12:28 PM
I'm sorry if this is sounds basic but I haven't seen it in any of the Powershell books or blogs(I don't think) and nobody has submitted anything in awyhile so here it goes...

Is there any way to make a Powershell script just run by clicking on it? I know in VB you could create a script and it would be executable by just clicking on it. I know this isn't VB but its been buggin' me for awhile and I thougt I'd ask. Not really a necessity just curiosity.
Thanks for anyone responding.

Super bad idea. The PowerShell team deliberately associated PS1 with Notepad to avoid the exact security issues that become such a pain with VBScript. Don't think of it as VBScript where you double-click the file, it runs, and WSH goes away... think of just always having the shell window open, so it's easy to type a script name to run it.

The furthest I would go would be to add a Run verb to the file extension, so you could right-click the file and select "Run in PowerShell." You can do all that through Explorer.
- Don Jones
www.ConcentratedTech.com
Subscribe (RSS) or visit for weekly PowerShell tips and lessons
RosarioMUser is Offline
New Member
New Member
Posts:15
Avatar

--
09 Nov 2007 06:12 PM  

Don

Is this in PrimalScript 2007 or a future release?

In both scenarios, I assume you need PowerShell installed on the host running the exe?

Thanks

DonJUser is Offline
PowerShell MVP
Basic Member
Basic Member
Posts:134
Avatar

--
09 Nov 2007 06:36 PM  
I'm not sure what you mean by "it."

PrimalScript 2007 (Pro and Enterprise) can package PS1 files and run them in a hidden console window. As for an embedded host, that would be some future release, if the dev team decides it's worth pursuing. I know right now it's just been the topic of some discussion.

And yes, PowerShell would need to be installed in order for the final EXE to actually run.
- Don Jones
www.ConcentratedTech.com
Subscribe (RSS) or visit for weekly PowerShell tips and lessons
valdezdjUser is Online
New Member
New Member
Posts:62

--
09 Nov 2007 08:32 PM  

The last part you said to "add a Run verb to the file extension" can you go more in depth on what you mean by that? I like that idea of right clicking and making it run in powershell.

Thanks,
valdezdj

ambersUser is Offline
New Member
New Member
Posts:16
Avatar

--
10 Nov 2007 12:04 PM  
I have used the PowerShell Prompt Here PowerToy in the past for this.  Lee's write up and links to the .inf downloads can be found here: 

http://leeholmes.com/blog/PowerShellPromptHerePowerToy.aspx
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer