Powershell script in package; Windows Desktop

SW
Shawn, Wilkerson
Stratix Corporation

Device: Windows Desktop

Goal: create directory file list (text file) POST copy routine

Summary:

- Package contains N number of files to be copied to a specific folder

- Prescript creates file list BEFORE copy (via Powershell)

- Postscript creates file list AFTER copy (via Powershell)

  • Syntax: start powershell.exe c:\temp\DirPost.ps1
  • Powershell scripts are located in c:\temp directory

I'm not able to get Powershell to run.  I can call it via the script window without issue but it fails to run via the package postscript.  I've considered using "shellexecute" but SOTI doesn't provide a list of "VERBS".

---- extract from SOTI Help file ----

shellexecute filepath -verb [-wseconds]

Where

  • -verb is the action you want the shell to execute
  • -w tells the command to wait for the specified length of time (in seconds) before executing

---------------------------------------

7 years ago
Windows
ANSWERS
S
SMod@Soti
7 years ago

Hi Shawn,

The command shellexecute is used to launch a registered app for a specific File extension as follows:

shellexecute

Launches the registered application for the given file extension.

Syntax:

shellexecute <filepath> <-verb> [-w<seconds>]

To launch the registered application for the given file extension:

shellexecute 1:\temp\temp.upg -open

shellexecute 1:\temp\temp.upg -run -w5

Can you please try to include the following script in the package to open a ps1 file:

powershell -noexit "& ""C:\temp\DirPost.ps1"""

Please let me know if you have any questions.

Thanks

SW
Shawn, Wilkerson
7 years ago
Using "start" or "shellexecute"?

powershell
-noexit "& ""C:\temp\DirPost.ps1"""
S
SMod@Soti
7 years ago

Use the script:

powershell -noexit "& ""C:\temp\DirPost.ps1"""

This script will execute the powershell file specified in the path.

SW
Shawn, Wilkerson
7 years ago

Unfortunately that didn't work. If I run the script from the Remote Control shell window it works if I remove 1 set of quotes, but it doesn't work from within the posti.cmd. 

S
SMod@Soti
7 years ago (edited 7 years ago)

Hey Shawn,

Can you please try the following script in the post-install script for your package and see if it executes the ps1 file:

start C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe C:\temp\DirPost.ps1

For some reason, if you specify just powershell.exe, MobiControl agent looks for powershell.exe in the agent folder.

Please let me know if it works.