Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Start-Process from array value with arguments

Start-Process from array value with arguments

Start-Process from array value with arguments

Hi All,

As a newbie on Powershell I thought lets create a handy script, haha. So I created a small script that checks if a crypt container is already mounted and if so, it will start some apps I stored in an array.

So far so good, however... Now I have SugarSync and I want to start it into the tray instead of full screen. This can be done by adding the argument "-startinTray". How hard can it be ?

Well... Too hard for me right now. I could use some help of the Tek Guru's smile

So this is the script:

$RunCheck = "c:\debug.txt"
$PostRun = "C:\path1\application.exe", "C:\'Program Files'\SugarSync\SugarSyncManager.exe -startinTray"

function RunApp([array]$Apps2Start)
    foreach ($App in $Apps2Start)
        $AppProc = $App.substring($App.lastindexOf("\")+1,$App.lastindexOf(".")-$App.lastindexOf("\")-1)
        if((get-process $AppProc -ea SilentlyContinue) -eq $Null)
            echo "Starting: $App" >> $RunCheck
            if ($App.substring($App.lastindexOf(".")) -eq ".ps1")
                & $App
                Start-Process $App

if ($PostRun)                                                     


So it checks if the app is already running by stripping off the file path and file extension and if no process is found, it will start the app. The echo is there to generate some easy debug output and it tells me that the app should be started.

Despite the echo that tells me the app starts, it is not. When I remove the argument, it does however start.
As you can see I want to keep it as simple as possible so others can use it to and without my help.

Now I hope that somebody has a suggestion that kicks me in the right direction smile

Thanks Acumen


RE: Start-Process from array value with arguments

I haven't tried this myself, but looking at the help the following seems to be the issue. Start-Process expects the program to run (the -FilePath parameter) to be just the program and nothing else. There is a separate parameter to Start-Process, -ArgumentList, which can be used to pass parameters to the process you're trying to start. You might want to try Invoke-Expression instead:


    Invoke-Expression $app

RE: Start-Process from array value with arguments

crobin1, this is working, thanks!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close