Discussion:
Running a 32 bit PowerShell Script with LRP on a 64 bit macnine
John Baughman
2015-04-18 22:30:09 UTC
Permalink
I have a PowerShell script that sends a request to QuickBooks which I am trying to run from 4D using Launch External Process. The system is 64 bit but QuckBooks is 32 bit so I have to use the 32 bit version of PowerShell.

Here is what I am passing to LRP which does not work...

$FilePath:="%SystemRoot%\\sysWoW64\\WindowsPowerShell\\v1.0\\powershell.exe &\""C:\\CC_FolioPro 2013\\Resources\\PS\\QB_TestConnection.ps1\"”
SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"true")
SET ENVIRONMENT VARIABLE("_4D_OPTION_BLOCKING_EXTERNAL_PROCESS";"false")
LAUNCH EXTERNAL PROCESS($FilePath)

Basically it is supposed to run the powershell script in the QB_TestConnection.ps1 file using the 32 bit version of PowerShell. I have left out a bunch of other environmental variables being set for clarity.

If, however, I comment out _4D_OPTION_HIDE_CONSOLE or set it to false and just pass the PowerShell part with out the path to the script file like this

$FilePath:="%SystemRoot%\\sysWoW64\\WindowsPowerShell\\v1.0\\powershell.exe"
// SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE”;"false")
SET ENVIRONMENT VARIABLE("_4D_OPTION_BLOCKING_EXTERNAL_PROCESS";"false")
LAUNCH EXTERNAL PROCESS($FilePath)

Then when the PowerShell Command Prompt opens, manually execute the script file like this...

&"C:\CC_FolioPro 2013\Resources\PS\QB_TestConnection.ps1”

It works perfectly.

Does anyone know what I might be doing wrong here. I must not be passing the script file path properly.

Thanks,

John


John Baughman
Kailua, Hawaii
(808) 262-0328
***@hawaii.rr.com





**********************************************************************
See how easy it is to extend your 4D solutions to Web and mobile. New opportunities await you with 4D v14!

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-***@lists.4D.com
**********************************************************************
Keisuke Miyako
2015-04-19 01:10:45 UTC
Permalink
I don’t think LEP expands environment variables like %SystemRoot%

that seems more like a cmd.exe feature.
Post by John Baughman
%SystemRoot%
John Baughman
2015-04-19 22:02:39 UTC
Permalink
OK. I got it working. I changed the file path to in include a -file cmdlet…

$FilePath:="%SystemRoot%\\sysWoW64\\WindowsPowerShell\\v1.0\\powershell.exe -file \""C:\\CC_FolioPro <smb://CC_FolioPro> 2013\\Resources\\PS\\QB_TestConnection.ps1\””

Works like a champ now.

If anyone is interested, it looks like I have figured out how to get 4D talking to QuckBooks via COM using Powershell. If there is interest shown, I will post some followup on what I a doing to the NUG after I have everything working. The end result might be a good candidate for a component.

John
Post by John Baughman
I have a PowerShell script that sends a request to QuickBooks which I am trying to run from 4D using Launch External Process. The system is 64 bit but QuckBooks is 32 bit so I have to use the 32 bit version of PowerShell.
Here is what I am passing to LRP which does not work...
$FilePath:="%SystemRoot%\\sysWoW64\\WindowsPowerShell\\v1.0\\powershell.exe &\""C:\\CC_FolioPro <smb://CC_FolioPro> 2013\\Resources\\PS\\QB_TestConnection.ps1\"”
SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"true")
SET ENVIRONMENT VARIABLE("_4D_OPTION_BLOCKING_EXTERNAL_PROCESS";"false")
LAUNCH EXTERNAL PROCESS($FilePath)
Basically it is supposed to run the powershell script in the QB_TestConnection.ps1 file using the 32 bit version of PowerShell. I have left out a bunch of other environmental variables being set for clarity.
If, however, I comment out _4D_OPTION_HIDE_CONSOLE or set it to false and just pass the PowerShell part with out the path to the script file like this
$FilePath:="%SystemRoot%\\sysWoW64\\WindowsPowerShell\\v1.0\\powershell.exe"
// SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE”;"false")
SET ENVIRONMENT VARIABLE("_4D_OPTION_BLOCKING_EXTERNAL_PROCESS";"false")
LAUNCH EXTERNAL PROCESS($FilePath)
Then when the PowerShell Command Prompt opens, manually execute the script file like this...
&"C:\CC_FolioPro 2013\Resources\PS\QB_TestConnection.ps1”
It works perfectly.
Does anyone know what I might be doing wrong here. I must not be passing the script file path properly.
Thanks,
John
John Baughman
Kailua, Hawaii
(808) 262-0328
John Baughman
Kailua, Hawaii
(808) 262-0328
***@hawaii.rr.com





**********************************************************************
See how easy it is to extend your 4D solutions to Web and mobile. New opportunities await you with 4D v14!

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-***@lists.4D.com
**********************************************************************
Loading...