Executing command in new powershell window

Hello guys, I'd like explore directions with gci, but the thing is that istead of using -recurse I'd like to open every single direction in new powershell window. I've made something like this:
function Get-ScriptDirectory
    $Invocation = (Get-Variable MyInvocation -Scope 1).Value
    Split-Path $Invocation.MyCommand.Path
$path = Get-ScriptDirectory
$paths = Get-ChildItem $path -Recurse | ?{ $_.PSIsContainer }
foreach ($element in $paths) 
    start-process powershell
    $new= $path, $element -join "\"  
    gci $new
But I don't know to make Powershelle execute command in new window. Start-process powershell only opens new window, but it doesn't import bolded commands. Can I get any suggestions?

Hi Shadston,
To add cmdlet in "-command", please refer to the script below:
Get-ChildItem (Split-Path $MyInvocation.MyCommand.Path) -Recurse -Directory |ForEach-Object{
start-process -FilePath powershell -ArgumentList @('-NoExit',"& {GCI '$($_.FullName)'; Write-Host 'Hello' }")
If there is anything else regarding this issue, please feel free to post back.
Best Regards,
Anna Wang
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

Similar Messages

  • Invoke command in new dos window

    is there any way that i can invoke a command in a new dos window from java application?
    such as
    runtime.exec("dir");
    it will open another dos window, and run dir in it.
    thanks

    it will open another dos window, and run dir in it.This works for me (win 2000):
    Runtime.getRuntime().exec("cmd /c start dir");

  • Execute commands inside new shell with a single line?

    I need some way to run series of commands as a single line, however the problem is that I am changing to another shell at one point and I am not sure how I can make commands execute in that new shell.
    Here is what I am trying to do (as I am running it now)
    adb shell
    ubuntu_chroot shell
    nohup /home/phablet/test/test2.sh
    I am able at the moment to call this:
    adb shell "ubuntu_chroot shell"
    But I am not sure how I can execute line that calls test2.sh after that on a single line.
    Last edited by kdar (2013-03-01 05:54:33)

    Does ubuntu_chroot have a --help flag or manpage?
    It's fairly common for shells to have a -c flag which will make them run the first argument in the new shell.
    Edit: Just looked through the Ubuntu Touch repos, ubuntu_chroot is (currently) only able to launch a shell, but it should be easy to modify it to just pass on the additional arguments to sh
    uchroot repo here if anyone's interested.
    Last edited by demize (2013-03-01 04:10:27)

  • CP5: Problems with Execute Javascript and New/Current window setting

    Hello everyone,
    I am at my wits' end trying to set this up properly, and I was hoping for some help.
    I have inserted a series of buttons designed to open other captivate-created HTM files. I wanted the files to be opened in a controlled window, so I used Execute_Javascript function on the buttons. Here is the code I am using:
    void window.open('filename.htm','name','height=680,width=906,left=0,top=0');
    I enter that code in the script window. I also want to set it to open in a new window (not reuse the current window), so I used the arrow to the right of the Script_Window button and set it to "New."
    When I publish and put it all up on a SharePoint server, it works fine. But then I had to correct a typo on one of my slides (unrelated to this functionality), so I corrected it and republished. The buttons which were working moments before now no longer function. It seems that the "New" setting I had set in the drop-down had reverted to "Current" without me touching it. The Javascript also stopped working. Clicking the button sometimes launches the file in the current window, sometimes in a new window, and sometimes the launch itself fails.
    Captivate just seems to forget the New/Current setting all by itself. And for some reason, the actual launching of the file via Javascript also just stops working.
    As a test to fix the non-functioning Javascript, I deleted the word "void" then saved the CPTX. Then I added the word "void" back in, saved it again, and published, and now it works. I can't make heads or tails of this, and it is very frustrating, especially since it will delay the delivery of my files.The javascript reads the exact same and yet sometimes it works and sometimes it doesn't.
    Has anybody seen this before? How on earth do I fix it?
    Thanks!

    Hi Jim,
    Thanks for the feedback. It's good to know that the New/Current issue is a bug and it's not just me.
    I tried your suggestion, and I am still having the same problem. I also tried switching to Open File or URL and entering this:
    javascript:void window.open('filename.htm','name','height=680,width=906,left=0,top=0' );
    Same problem. Sometimes it works and sometimes it doesn't. Code is exactly the same. I can literally put the code in and publish, it works fine, then I can go back into the project, change something completely unrelated (i.e., not touch the javascript), publish again, and now it doesn't work.
    Thanks for any additional feedback.

  • A weird question on opening a new finder window

    this is not a big deal, but it really bugs me. when you have a finder window open and do apple-N to get a new one, it puts the new one right on top of the one already open. this is totally stupid. 99% of the time when i open a new window it's because i want to drag a file from one location to another, in which case i have to first move the new window. is there some way you can have it put new windows someplace else other than right on top of the current one?
    and please, please, please dear apple, give us tabs in finder windows like in safari. i keep expecting it to happen in each new system upgrade, and it keeps never happening.

    ...when you have a finder window open and do apple-N to get a new one, it puts the new one right on top of the one already open... is there some way you can have it put new windows someplace else other than right on top of the current one?
    In addition to the excellent suggestions regarding the Sidebar offered earlier, you might consider creating an AppleScript and adding it to your Finder window's toolbar. Once added to the toolbar, the script would serve as a button, which, when clicked on, would open a fully viewable new Finder window positioned above and slightly to the left of the existing Finder window. The existing Finder window would be repositioned if necessary and set to a size matching the dimensions of the new window.
    The example scripts below were created with the assumption that your Home folder's Finder window opens when you press ⌘N. These scripts can be modified so that another window is opened instead by replacing the word "home" where it appears in the script with "desktop" or "documents" or "applications" etc. To open the "Computer" window use the command *make new Finder window* exclusively. Paths to non system-level folders, or user-created folders, can be specified by using an *open "Macintosh HD:path:to:folder"* command.
    Copy and then paste either block of code below into your AppleScript Script Editor (Applications > AppleScript > Script Editor). From the Script Editor's File menu choose Save As > File Format: application, and leave the Options unchecked.
    To add the button to your Finder window's toolbar, simply open any Finder window and drag the saved AppleScript icon to a convenient location on the toolbar. Let go of your mouse when you see the round green "+" indicator.
    +This script might work best with a monitor set to a minimum 1024 x 768 screen resolution:+
    *tell application "Finder"*
    activate
    *make new Finder window to (path to home folder)*
    *set the bounds of window 1 to {70, 59, 955, 399}*
    *set the bounds of window 2 to {100, 403, 985, 743}*
    *activate window 2*
    *end tell*
    +This version would be more suitable for a monitor set to 800 x 600 screen resolution:+
    *tell application "Finder"*
    activate
    *make new Finder window to (path to home folder)*
    *set the bounds of window 1 to {85, 47, 715, 317}*
    *set the bounds of window 2 to {115, 320, 745, 595}*
    *activate window 2*
    *end tell*
    Good luck.

  • Windows Image Deployment - WinPE - Execute Command After Server Image Deployment but Before WinPE Reboot

    Simplified version: Execute command in WinPE after server image deployment but before WinPE reboots.
    I have a custom ISO with a boot.wim and install.wim for deploying Windows Server to our environment. Our environment does not allow DHCP and we have no static IPs available at build time so this will all be done with no internet connection during all phases
    of deployment.
    We have a custom HTA form that generates an XML file based on user input and stores it on the RAMDisk during WinPE. How can we move this XML file from the RAMDisk to the deployed Windows Server image?
    Thanks in advance, Tim

    I believe you should be able to do this during the offlineServicing configuration pass.  You would just need to add into your answer file a command or script to copy from the XML file over to the newly created C:\ drive.  
    I don't have System Image Manager installed on the computer I'm using but if I recall there is a spot during the offlineServicing pass to execute custom commands. You would just add your script path there, the WinPE system drive letter is
    X:\ , and I think the target drive letter Windows is installed to might change depending on how many devices you have hooked up so do a test install and hit SHIFT-F10 , from there you can run diskpart > list volume to see where the new Windows
    install is located. 
    Another alternative could be using a USB drive as your install media, then you can run a script during offlineServicing to copy that XML over to the USB drive.

  • UI Mass Command opening new window

    Hi all,
    I need your help. I would like to create new UI Mass Command which will open new IE window.
    For better understanding of my problem:
    I've created UI Mass Command which take selected resources and add them to ZIP archive. The final ZIP stream I store to a static class. Then I create servlet which loads the ZIP stream from the static class and offer it to user for downloading. But I need modify the command to be able call the servlet in new window.
    Do you have any idea how to do that? Thank you in advance for any reply!
    Regards
    Zbynek

    Hi Zbynek ,
    You need to implement a class which extends AbstractCommand class and in the method getLinkAttributes() you can return the link that should be executed when user click the UICommand.
    Check this to know, how to implement UICommand:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/kmc/Implementing%20Flexible%20UI%20One-Step-Screenflow.article
    Here is getLinkAttributes implementation:
    public LinkAttributes getLinkAttributes() {
            try {
                String path = getResource().getRID().getPath();
                     String irjString = pcr.getServletRequest().getContextPath();
                   String linkRef = irjString + "/servlet/prt/portal/prtroot/YourComponent";
                return new LinkAttributes(
                    "javascript:me.window.open('"
                        + linkRef
                        + "?path="
                        + path
                        + "', 'myWin_"
                        + System.currentTimeMillis()
                        + "', 'left=250, top=250, toolbar=no,status=no,menubar=no,resizable=yes,scrollbars=yes,width=700,height=350');",
                    "_top",
                    true);
            } catch (ResourceException e) {
                log.severe(e, "Operation failed");
                return null;
    Greetings,
    Praveen Gudapati
    p.s. Points are always welcome for helpful answers

  • Command to open a PDF generated Oracle Report in New browser window

    I know this is probably something for the Oracle Forums but I'll ask anyway because I can't find any info out there on this, without some extra work.
    I am generating a PDF file from 10g Oracle reports on Linux RHEL 5 and storing the PDF file to the server. I can send that PDF file directly to a printer with the "lpr" command and that part works fine.
    What I'm wanting to do now is "View" the PDF from within the server in a new window. We are using RHEL 5 (Linux) platform and I'm trying to see if there is a way to open the file with a "command line" command that will open it in a new browser window or new window period (opening it with Adobe Acrobat).
    Does anyone have a command that will do this? Otherwise, how has everyone else been handling this. The idea of just viewing the previously generated PDF Report file will save us overhead on our database servers because they won't have to re-run some of the same reports over and over.
    Any help and assistance is appreciated.
    Chris

    Several options:
    - If you only want to show the pdf to the client without printing, use destype=cache and use WEB.SHOW_DOCUMENT after the RUN_REPORT_OBJECT (for examples search the forms-forum, there are lots)
    -If you have to generate the pdf to a file to get it printed, you could
    +use WEBUTIL_FILETRANSFER.AS_TO_CLIENT after the printing to transfer the file to the client, then use CLIENT_HOST to view it.
    +map the appserver-directory you generate the report to as a virtual directory in the application-server then use WEB.SHOW_DOCUMENT to directly access the generated file via url.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to open new browser window on click of command button

    Hi,
    We have a requirement to open an image in new window when a command button is clicked. Is there any sample explaining how to do that?
    Thanks in Advance,
    Pradeep

    Hi,
    I have to load an applet viewer in the new browser window. I have URL to the PDF.
    I ma able to load the applet viewer in new browser window using javascript. But I have to load the new PDF if the same window in already opened.
    The issue here is , i am loosing the window handle if the parent page is refreshed. I want to store the window handle in session scope variable and use the same.
    How do i update the session scope variable using javascript?
    Thanks and Regards,
    Pradeep

  • When my most front window is a safari one and I use the shortcut key "Command N", it opens a new finder window and a new safari window at the same time. Why does it happen?

    When my most front window is a safari one and I use the shortcut key "Command N", it opens a new finder window and a new safari window at the same time. Why does it happen?

    I just found the solution!
    Niel
    Re: Why is my Finder window popping up when I open my Safari window? 
    Jan 20, 2008 7:58 PM (in response to alak)
    Open the General tab of the Safari preferences and correct the home page; the default page is this one. If it has become set to a folder on an FTP server or a local drive, that request will be sent to the Finder. (28252) 
    iMac Late 2007 Core 2 Duo, Mac OS X (10.5.1)

  • How can one powershell.exe session start up a new powershell.exe session in a new window?

    How can one powershell.exe session start up a new powershell.exe session in a new window?

    Er... good luck with that.  :)  If you know the shortcut that was used to launch the current window, you could pass that shortcut path to Start-Process, but that would only work if you did not move or resize the original window, etc.  For
    example, on my computer I can do this:
    Start-Process 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell\Windows PowerShell.lnk'

  • [bash] make command appear in new terminal window

    I have a bash command that uses aria2 to download something. The problem is that it download silently in the background. I want it to display in a new terminal window so I can see the download stats. How can I do this?

    urxvt -e "some_command" ?

  • WAD execute in browser (new window)

    Hi All,
    When I push the button 'Execute in browser' after creating or changing a web template, the WAD publishes the Web report in my last opened browser Window.
    Nine out of ten times, this Window contains relevant information like Webmail, or Sap serviceplace or SDN
    Is there a setting in WAD that forces the WAD to open a new browser window when you use the button Execute in Browser instead of using the last opened one. (Grrr)
    Thanx for the help!
    Best regards,
    Almar van Pel

    Hi Almar,
    Try this: Internet Explorer > tools > internet options > Advanced tab > Browsing > Uncheck the Reuse Windows for Launching Shortcuts option.
    Hope this helps...

  • Execute commands remote with PSSession

    Hi,
    I am trying to write a script that is executed on Server A but connects to Server B and executes the commands with remote Powershell.
    I am currently just trying some simple commands since it's the first time I have tried the remote Powershell function. I connect to a server which is working fine, but if I do a simple command like:
    $FoundFiles = Get-ChildItem - Path "C:\Temp"
    it returns an error telling me that it cannot find the path. If I do the same and use "C:\Windows" it works.
    If I enter the commands manually in a console everything also works as expected.
    Lasse
    /Lasse

    If you do this:
    Enter-PSSession -Name TestConnection
    $tmpFiles = get-childitem -path "C:\temp"
    you will be running  from the remote system and c:\temp will have to be on the remote system.  Either copy the file there or use invoke.
    Spend some time testing the commands until you sort out how remoting works.   When you enter a sessin your prompt changes to tell you you are now running on the remote system and all references are to the remote system.
    This works the same but references are local and execution is remote:
    $session=New-PSSession  -ComputerName Servername
    invoke-command -file c:\temp\script.ps1 -Session $session -ArgumentList '-param1 xxxx','-param2 vvvvv'
    I can also alter the session:
    PS C:\scripts> invoke-command -command {$newvar='hello remote'} -Session $session
    PS C:\scripts> invoke-command -command {$newvar} -Session $session
    hello remote
    Notice the session is retained. I can load modules in one command or file and use them in another:
    We can also use -AsJob for very long running scripts and invoke against a list of computers.
    it is not just a telnet like session but a full remote targetable session.
    ¯\_(ツ)_/¯

  • File Open Issues - document library pdf file to open in new browser window

    Hi
    I have a requirement to open the document library containing pdf file to open in new browser window. So far I have tried following steps but could not get it to work.
    1. Changing Document library advance setting to open the document in browser (have tried others as well).
    2. SharePoint web application setting changed as Permissive instead of Strict. Here the pdf file opens in browser but redirect from document library instead of new window(Also tried adding Target=”_blank” and no change).
    3. Executed the powershell script to adding MIME type to see if it works but no change.
    $webApp = Get-SPWebApplication http://SharePointSite
    If ($webApp.AllowedInlineDownloadedMimeTypes -notcontains "application/pdf")
    Write-Host -ForegroundColor White "Adding PDF MIME Type..."
    $webApp.AllowedInlineDownloadedMimeTypes.Add("application/pdf")
    $webApp.Update()
    Write-Host -ForegroundColor White "Added and saved."
    Else
    Write-Host -ForegroundColor White "PDF MIME type is already added."
    4. Open the Doc library and modified ALLItems.aspx to add Target= “_blank”
    5. I have already tried solutions suggested in the link:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/9db08c4a-b53c-419a-84f8-001c194d1311/how-to-open-sharepoint-document-library-pdf-file-in-new-window?forum=sharepointadminlegacy
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/530e2ea1-d77d-491c-935f-04f536e439a5/open-a-pdf-document-to-a-new-browser-in-the-document-library-web-part?forum=sharepointadminlegacy
    http://mindsharpblogs.com/todd/archive/2005/08/16/654.html
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/7b6091df-4657-4799-ba02-259ebd7e4b7c/pdf-doesnt-open-in-document-library?forum=sharepointadminlegacy
    Appreciate if there are any working solution from any of you. Many Thanks

    I found a solution which works only in the development. No idea when I compared, Browser MIME type is enabled, STRICT browser type is configured for web application. on the document library advance setting, default to open in new browser. Both configurations
    are identical but I am able to open pdf file in new window in my developing using jquery script
    http://blog.ithinksharepoint.com/2011/02/21/open-pdf-files-from-a-document-library-in-a-new-window/ but the same does not work on production server :(
    Any help experts?
    Thanks

Maybe you are looking for