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
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
}
else
{
Start-Process $App
}
}
}
}
if ($PostRun)
{
RunApp($PostRun)
}
[/color red]
--------------------------------------------
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
Thanks Acumen
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
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
}
else
{
Start-Process $App
}
}
}
}
if ($PostRun)
{
RunApp($PostRun)
}
[/color red]
--------------------------------------------
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
Thanks Acumen