If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Reply to Thread

Your Message

What's the name of our main installation product (in lowercase letters)?

Title:

Post Icons:

No icon

You may choose an icon for your message from this list

Additional Options

Miscellaneous Options:

Automatically parse links in text

Will turn www.example.com into [URL]http://www.example.com[/URL].

Topic Review (Newest First)

11-30-2017, 03:14 AM

linder

Re: Run Program - powershell.exe issue

Hi Kurt,

perfect!!! Thanks for the update.

Friedrich

11-29-2017, 01:41 PM

kboller

Re: Run Program - powershell.exe issue

Hi Friedrich,

It was the difference between running the 32-bit vs 64-bit command prompt that was the issue. That was what I needed to know.

Thank you!,

Kurt

11-15-2017, 12:03 PM

linder

Re: Run Program - powershell.exe issue

Hi Kurt,

if you run a command line interpreter from an application that is running in x86 mode (32-bit processing) then the 32-bit interpreter is executed. In SetupBuilder, you can use the "Set x64 mode..." script function to switch the setup application (at runtime) into 64-bit processing mode. See attached screenshot. After doing this, the setup will execute the 64-bit interpreter. Don't forget to disable x64 mode!

Does this help?

Friedrich

11-15-2017, 04:59 AM

kboller

Re: Run Program - powershell.exe issue

The 32-bit program vs 64-bit may be the factor. This is running on a 64-bit system. This brings up more questions:

1) How do you tell which mode the command prompt is running in?

2) Can you tell me which mode (32 vs 64) that the batch file will run in when executed from Setup builder?

3) If that's not the same as running it from the command prompt in Windows, how do I initiate it so that it's the same?

Thanks,

Kurt

11-15-2017, 04:15 AM

linder

Re: Run Program - powershell.exe issue

Kurt,

please note that there is a fundamental difference between running a batch file from a command line interpreter and executing it from a Windows application through, say, CreateProcess or ShellExecuteEx Windows APIs. To launch external programs from a Windows application, you have to use CreateProcess or ShellShecute(Ex). In your case, SetupBuilder executes Powershell (gives *complete* control to it) and waits until Powershell returns. If your script fails when executed from a CreateProcess or ShellExecute Windows APIs then there is a problem with the script (this has nothing to do with SetupBuilder). Remember: Powershell executes your script, not SB. For example, your script expects a specific current folder or access to a specific registry branch. To check what the problem in your script is, simply write your own small 32-bit program with Visual C or Delphi or Clarion and call your script with the exact same command line parameters your are currently using in SB (call PS/your script and wait for its termination). I am sure you'll get the very same error.

But if it works from the command line interpreter, why don't you simply call your batch file from the installer in an interpreter? From a Windows program, you do it via CMD.EXE. Just calling the batch without CMD /C is not correct and might fail.

For example:

cmd /C c:\mydir\MyBatch.bat

in a "Run Command Line..." or "Run Program..." SB function.

As a side note: perhaps this is a x64 operating system and your script tries to read a 64-bit registry value, but the value is stored in the 32-bit branch (or vice-versa!). And that's why it fails when running Powershell in 32-bit mode. Maybe it's looking in the wrong registry branch?

32-bit programs and 64-bit programs that are running on a x64-based version of Windows operate in different modes and use the following sections in the registry:

1. Native mode 64-bit programs run in Native mode and access keys and values that are stored in the following registry sub key:

HKEY_LOCAL_MACHINE\Software

2. 32-bit programs run in WOW64 mode and access keys and values that are stored in the following registry sub key:

HKEY_LOCAL_MACHINE\Software\WOW6432node

Does this help a bit?

Friedrich

11-14-2017, 03:17 PM

kboller

Re: Run Program - powershell.exe issue

So to summarize what's happening (sorry, I should have done that in the last reply). When the batch file is run from an un-elevated command prompt, the script runs fine and is able to query the registry for information about the SQL server that currently exists. However when running the same batch file/script from the Run Command box in setup builder, it can not query the registry for sql server information. Even when UAC is completely turned off, the same results occur.

Thanks,

Kurt

11-14-2017, 12:28 PM

kboller

Re: Run Program - powershell.exe issue

I tried the Run Command Line route and it's better however still not working correctly. This is an excerpt from the PowerShell script. When running the batch file manually, everything works fine. But when running the batch file from the SetupBuilder exe, it fails on the highlighted line of code below. For some reason it has an issue querying the registry.

I googled for "A Positional Parameter Cannot Be Found That Accepts Argument Powershell" and there are tons of tips.

Here is one:

When you wrap this script in an executable file and use the same command line, it used to fail, because all input strings were interpreted as parameter values. In this case, ‘-Parameter’ was interpreted as the value of the Word parameter and ‘PowerShell’ was interpreted as the value of the Number parameter. The script failed when Windows PowerShell couldn’t convert ‘PowerShell’ to a integer."

BTW, if I were you, I would try it again with "Run Command Line...". This will also use the Windows CreateProcessA Windows API. Perhaps this lets you find out what the problem with the powershell script is...

Please keep us posted.

Friedrich

11-10-2017, 09:18 AM

linder

Re: Run Program - powershell.exe issue

Kurt,

I am afraid I don't know how to help in your specific case. SetupBuilder simply uses the Windows CreateProcess API (to start PowerShell) and passes the parameters that you defined to the Windows API. In other words, SB launches Powershell and waits until it terminates (powershell handles the script processing). If this fails then at least one of the parameters passed to PowerShell is not correct.

Friedrich

This thread has more than 10 replies.
Click here to review the whole thread.