PoshCode Archive  Hex Artifact Content

Artifact 986f556e3e8cf6e7a7c97e8870ac6e43b00a28628e9c5f6c2c9cf37bf73b8b6b:

  • File Start-Process.ps1 — part of check-in [6b2b78d2ae] at 2018-06-10 14:23:30 on branch trunk — This is a simple function that can “Start” apps and return the PROCESS object. In particular, it can start URIs, documents, and apps defined in the “App Paths” registry, and basically anything that you could start from the run dialog. (user: unknown size: 601)

0000: 23 20 65 6e 63 6f 64 69 6e 67 3a 20 61 73 63 69  # encoding: asci
0010: 69 0d 0a 23 20 61 70 69 3a 20 70 6f 77 65 72 73  i..# api: powers
0020: 68 65 6c 6c 0d 0a 23 20 74 69 74 6c 65 3a 20 53  hell..# title: S
0030: 74 61 72 74 2d 50 72 6f 63 65 73 73 0d 0a 23 20  tart-Process..# 
0040: 64 65 73 63 72 69 70 74 69 6f 6e 3a 20 54 68 69  description: Thi
0050: 73 20 69 73 20 61 20 73 69 6d 70 6c 65 20 66 75  s is a simple fu
0060: 6e 63 74 69 6f 6e 20 74 68 61 74 20 63 61 6e 20  nction that can 
0070: e2 80 9c 53 74 61 72 74 e2 80 9d 20 61 70 70 73  ...Start... apps
0080: 20 61 6e 64 20 72 65 74 75 72 6e 20 74 68 65 20   and return the 
0090: 50 52 4f 43 45 53 53 20 6f 62 6a 65 63 74 2e 20  PROCESS object. 
00a0: 20 49 6e 20 70 61 72 74 69 63 75 6c 61 72 2c 20   In particular, 
00b0: 69 74 20 63 61 6e 20 73 74 61 72 74 20 55 52 49  it can start URI
00c0: 73 2c 20 64 6f 63 75 6d 65 6e 74 73 2c 20 61 6e  s, documents, an
00d0: 64 20 61 70 70 73 20 64 65 66 69 6e 65 64 20 69  d apps defined i
00e0: 6e 20 74 68 65 20 e2 80 9c 41 70 70 20 50 61 74  n the ...App Pat
00f0: 68 73 e2 80 9d 20 72 65 67 69 73 74 72 79 2c 20  hs... registry, 
0100: 61 6e 64 20 62 61 73 69 63 61 6c 6c 79 20 61 6e  and basically an
0110: 79 74 68 69 6e 67 20 74 68 61 74 20 79 6f 75 20  ything that you 
0120: 63 6f 75 6c 64 20 73 74 61 72 74 20 66 72 6f 6d  could start from
0130: 20 74 68 65 20 72 75 6e 20 64 69 61 6c 6f 67 2e   the run dialog.
0140: 0d 0a 23 20 76 65 72 73 69 6f 6e 3a 20 30 2e 31  ..# version: 0.1
0150: 0d 0a 23 20 74 79 70 65 3a 20 66 75 6e 63 74 69  ..# type: functi
0160: 6f 6e 0d 0a 23 20 6c 69 63 65 6e 73 65 3a 20 43  on..# license: C
0170: 43 30 0d 0a 23 20 78 2d 70 6f 73 68 63 6f 64 65  C0..# x-poshcode
0180: 2d 69 64 3a 20 37 34 31 0d 0a 23 20 78 2d 61 72  -id: 741..# x-ar
0190: 63 68 69 76 65 64 3a 20 32 30 30 38 2d 31 32 2d  chived: 2008-12-
01a0: 32 31 54 30 35 3a 34 31 3a 32 34 0d 0a 23 0d 0a  21T05:41:24..#..
01b0: 23 0d 0a 66 75 6e 63 74 69 6f 6e 20 53 74 61 72  #..function Star
01c0: 74 28 24 61 70 70 2c 24 70 61 72 61 6d 29 20 7b  t($app,$param) {
01d0: 0d 0a 20 20 20 69 66 28 24 70 61 72 61 6d 29 20  ..   if($param) 
01e0: 7b 0d 0a 20 20 20 20 20 20 5b 44 69 61 67 6e 6f  {..      [Diagno
01f0: 73 74 69 63 73 2e 50 72 6f 63 65 73 73 5d 3a 3a  stics.Process]::
0200: 53 74 61 72 74 28 20 24 61 70 70 2c 20 24 70 61  Start( $app, $pa
0210: 72 61 6d 20 29 0d 0a 20 20 20 7d 20 65 6c 73 65  ram )..   } else
0220: 20 7b 0d 0a 20 20 20 20 20 20 5b 44 69 61 67 6e   {..      [Diagn
0230: 6f 73 74 69 63 73 2e 50 72 6f 63 65 73 73 5d 3a  ostics.Process]:
0240: 3a 53 74 61 72 74 28 20 24 61 70 70 20 29 0d 0a  :Start( $app )..
0250: 20 20 20 7d 0d 0a 7d 0d 0a                          }..}..