![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
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>
|
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | ||
|
Guest
Posts: n/a
|
I need some advice. Occasionally, some of my scripts are run by the
technician manually and are not automatically invoked. In the case of powershell files, i am using either a VBS file or a BAT file to invoke the PS1 file because PS1s are designed to open with notepad by default. Can anyone offer me some advice as to a way that would allow the tech to just execute the PS1 file by clicking on it? |
||
|
|
|
|
|
|
#2 | ||||||||||||||
|
Guest
Posts: n/a
|
By default ps1 files are not executable by double clicking. This is designed
to prevent some of the issues seen with VBScript code that can be run by malware. If you want to make the scripts accessible to running manually without access to the PowerShell prompt why not look at using PowerGUI -- Richard Siddaway All scripts are supplied "as is" and with no warranty PowerShell MVP Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "greatbarrier86" wrote:
|
||||||||||||||
|
|||||||||||||||
|
|
#3 | ||
|
Guest
Posts: n/a
|
You can make a shortcut to WindowsPowershell - the executable, and
name that shortcut what you want. After the shortcut is made, you can then append to the end of the 'Target' field -nologo -command &'\\path \to\your\script.ps1' and when someone double clicks the link, and presuming you have the execution policy set to run your script, a shell will be created and your script will run it. May not be the most elegant, but it works. Essentially the same as scheduling a powershell script in task manager. |
||
|
|
|
#4 | ||
|
Newbie
![]() Join Date: Dec 2007
XP 32bit
Posts: 1
|
a bat file
----------------------------------------- ftype Microsoft.PowerShellScript.1="C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe" -noexit ^&'%%1' assoc .ps1=Microsoft.PowerShellScript.1 ----------------------------------------- auto exit: remove -noexit |
||
|
|
|
|
|
#5 | ||||||||||||||
|
Guest
Posts: n/a
|
Thanks,
I like the shortcut idea. The problem with PowerGui is that i dont want to install it on all the computers i am deploying. Thanks for the help guys! "NilVeritas@xxxxxx" wrote:
|
||||||||||||||
|
|||||||||||||||
|
|
#6 | ||||||||||||||
|
Guest
Posts: n/a
|
greatbarrier86 wrote:
my name attached to it... ;-) Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com |
||||||||||||||
|
|||||||||||||||
|
|
#7 | ||||||||||||||||||||||||||
|
Guest
Posts: n/a
|
What? Huh? Damn...well if you were to tell me, how would i have to go about
asking? "Marco Shaw [MVP]" wrote:
|
||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||
|
|
#8 | ||||||||||||||||||||||||||
|
Guest
Posts: n/a
|
I have the same problem because I create powershell scripts that I send
to my colleagues to run. I have been toying around with the idea of creating a small application that I would associate the .ps1 extension to and accept the PowerShell script as a parameter. So you would double-click the .ps1 file and it would bring up a window asking you to confirm that you really want to do it and execute the script in PowerShell if you accept. And it would have lots of warnings. Mark Marco Shaw [MVP] wrote:
|
||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||
|
|
#9 | ||
|
Newbie
![]() Join Date: Apr 2008
Vista Ultimate x64
Posts: 2
|
To avoid the concerns of changing the ps1 extension association, how about adding a right click choice to SendTo PowerShell?
Here is a little VBScript I wrote to set this up. Code:
'========================================================================== ' ' NAME: SendToPowerShell.vbs ' ' AUTHOR: Mark D. MacLachlan , The Spider's Parlor ' URL: Home ' DATE : 4/24/2008 ' COPYRIGHT (c) 2008 All Rights Reserved ' ' COMMENT: Adds SendTo right menu choice for PowerShell. ' ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO ' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A ' PARTICULAR PURPOSE. ' ' IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS ' BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY ' DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, ' WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ' ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE ' OF THIS CODE OR INFORMATION. ' '========================================================================== Set WSHShell = CreateObject("WScript.Shell") Set WSHNetwork = CreateObject("WScript.Network") Set objFSO = CreateObject("Scripting.FileSystemObject") WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%") strSendToFolder = WSHShell.SpecialFolders("SendTo") If Not objFSO.FolderExists(Windir & "\sysWOW64") Then strPathToNotepad = WinDir & "\system32\WindowsPowerShell\v1.0\powershell.exe" Set objShortcut = WSHShell.CreateShortcut(strSendToFolder & _ "\PowerShell.lnk") objShortcut.TargetPath = strPathToNotepad objShortcut.Save Else strPathToNotepad = WinDir & "\sysWOW64\WindowsPowerShell\v1.0\powershell.exe" Set ps86 = WSHShell.CreateShortcut(strSendToFolder & _ "\PowerShell(x86).lnk") ps86.TargetPath = strPathToNotepad ps86.Save strPathToNotepad = WinDir & "\system32\WindowsPowerShell\v1.0\powershell.exe" Set ps64 = WSHShell.CreateShortcut(strSendToFolder & _ "\PowerShell.lnk") ps64.TargetPath = strPathToNotepad ps64.Save End If |
||
|
|
|
|
|
#10 | ||||||||||||||
|
Guest
Posts: n/a
|
You shouldn't have to add anything to you shortcut. It should pass the file
to the script in the $args collection. Typically accessed as $args[0] "Doug Griffin" wrote:
|
||||||||||||||
|
|||||||||||||||
|
|
|
|