using Shell

SonicSue

Member
Licensed User
How do I add / use an external, .exe file in my program using Shell? Specifically, where does the external program need to be placed to access it using Shell("myprogram", "")? And am I correct in putting the Shell command in the app_start sub? Thanks in advance.
 

agraham

Expert
Licensed User
Longtime User
Shell takes a full path so you can put the exe anywhere you want. Placing it in the project folder and using Shell(AppPath & "\whatever.exe") is convenient. Shell also accepts document filenames of registered types like "Something.txt" or "SomethingElse.jpg" and will start the associated program.

With Shell you can start a program but you won't be told when or if it exits. If you need that information then the Process object in http://www.b4x.com/forum/additional-libraries/4805-threading-library-version-2-a.html#post27720 provides more control than Shell. You can also use the Door library http://www.b4x.com/forum/code-samples-tips/2040-shell-wait.html
 

SonicSue

Member
Licensed User
Is there a way to use your first suggestion and have the file included in the resulting .cab file after compilation? Or do I have to use the threading example for that? (which I don't understand at this point, but will be reviewing samples while I await your response). Thanks again.
:sign0104:
 

mjcoon

Well-Known Member
Licensed User
Is there a way to ... have the file included in the resulting .cab file after compilation?

The SetupBuilder program that you can find via the forum will allow you to include any DLL or EXE in the .CAB file. This is a separate step to follow the compilation.

HTH, Mike.
 

SonicSue

Member
Licensed User
Here's my code that involves an error I am getting with flb:

Sub App_Start
Form1.Show
flb.New1("Form1",B4PObject(1))
Total.Focus
End Sub

Sub flb_Resize 'Fires when the user changes the screen orientation

If Form1.Width > Form1.Height Then
Msgbox("Landscape")
Shell(AppPath, "\BtnsL_90.exe")
Else
Msgbox("Portrait")
Shell(AppPath, "\BtnsL_90.exe")
End If
End Sub

I'm getting a runtime error on my HTC Touch / AT&T Fuze when I open the keyboard and the screen flips to landscape:

An error occurred on sub_main_flb_resize.

Win32Exception
Continue?

If I continue, there are no buttons on my app. If I don't continue, it exits.

What I am trying to do is have by app rotate when the keyboard is pulled out. on the device. As it happens now, the screen rotates and the buttons are lost because the form does not fit on the screen in landscape, and there are no scroll bars. Any guidance on how to fix this is greatly appreciated. Thanks in advance.
:sign0104:
 

konisek

Member
Licensed User
Longtime User
How can I run a shortcut
B4X:
Shell(AppPath, "\program.lnk", "")?

I cannot call
B4X:
Shell(AppPath, "\program.exe", "")
because the program.lnk does not reffer to program.exe but contents a script, i.e.
22#ctlpnl cplmain.cpl,4,2?shellres.dll,-13900

In other words, I need to run an executable file (batch file) like program.bat in Windows. How to create a batch file? I created a file and saved it as "program.bat". However it does not run on PPC.
 
Last edited:

konisek

Member
Licensed User
Longtime User
Yes, you are right, I copied it from previous post.
Actually my exact syntax is:
B4X:
Shell("\SDMMC\Zastupci\program.lnk","")
But how do I create a batch file program.bat?
I will use
B4X:
Shell("\SDMMC\Zastupci\program.bat","")
 
Last edited:

agraham

Expert
Licensed User
Longtime User
But how do I create a batch file program.bat[/I
Notepad, Wordpad, Word, FileOpen/Write/Close .... :confused:

However you mentioned PPC. Running batch files is not implemented on Windows Mobile. You will need to run an actual application that can interpret your batch file. You could try MortScript from here www.sto-helit.de - MortScript
 

konisek

Member
Licensed User
Longtime User
Hm, on the device I wanted to use the Shell command to run a script . As the Shell command accepts a program.exe only and cannot use program.lnk (shortcut containing script), I wanted to create a batch file.bat containing the script and run it on the device.
It is not possible either because you cannot run file.bat on the PPC, or with Shell command.
So there is no easy way to run a script in B4PPC on the device?
For example this program.lnk contents the following script
B4X:
23#"ctlpnl" cplmain.cpl,17?shellres.dll,-13911
and pressing the program.lnk opens Start\Settings\Connections\Wi-Fi (Configure Wireless Network).
Do I have to really create a program.exe containing the script with another software?:BangHead:
 

konisek

Member
Licensed User
Longtime User
Sorry, I deleted it. I found the correct solution just after I had put my question.
B4X:
Shell("pword.exe", AppPath & "\arch_osk.txt")
 
Top