[Solved] SystemShellExecute question

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
zabolyx
Posts: 216
Joined: Fri Aug 07, 2009 7:28 pm

[Solved] SystemShellExecute question

Post by zabolyx »

When trying to use SystemShellExecute to run a command line application I'm having issues with it.

I can get the file to pull up help... I can get it to open Notepad.exe

When trying to pass more than one parameter as a string it refuses to work.

String I'm trying to pass... "-e 333313.jpg 333313.b64" according to the API documentation that the parameters are to be space separated (as they are)...

The executable file is in the same directory as the files being passed to it... but it doesn't want to accept the files as well.

Also tried this with just Shell and got nowhere there either.
Last edited by zabolyx on Wed Dec 29, 2010 12:41 am, edited 1 time in total.
OOo 3.1 On Windows XP SP3 (Home)
Running portables of 2.4, 3.0, 3.1, and 3.2 on XP SP3 (Work)
OOo BASIC user

My contribution to the OOo Community code and more
https://sites.google.com/site/ooomacrolog/
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: SystemShellExecute question

Post by Charlie Young »

zabolyx wrote:When trying to use SystemShellExecute to run a command line application I'm having issues with it.

I can get the file to pull up help... I can get it to open Notepad.exe

When trying to pass more than one parameter as a string it refuses to work.

String I'm trying to pass... "-e 333313.jpg 333313.b64" according to the API documentation that the parameters are to be space separated (as they are)...

The executable file is in the same directory as the files being passed to it... but it doesn't want to accept the files as well.

Also tried this with just Shell and got nowhere there either.
Let me guess. "-e" means "encode" and the two files are the input file and output file. :D

This VC++ program just echoes the command line parameters.

Code: Select all

// echocommandline.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <conio.h>
using namespace std;



int _tmain(int argc, _TCHAR* argv[])
{
	int i;
	for(i = 0;i < argc;i++) {
		wcout << argv[i] << endl;
	}
	_getch();
	return 0;
}
I test it from within Calc like this

Code: Select all

Sub testViewParameters
	ViewParameters("-e 333313.jpg 333313.b64")
End Sub

Sub ViewParameters(CmdString As String)
	Dim SysShell
   	Dim ProgramUrl As String
   	ProgramUrl = "C:\Documents and Settings\Charlie\My Documents\Visual Studio 2010\Projects\echocommandline\Debug\echocommandline.exe"
   	SysShell = createUNOService("com.sun.star.system.SystemShellExecute")
   	SysShell.Execute(ProgramUrl,CmdString,0)
End Sub


and as expected, I get 4 lines:

Code: Select all

C:\Documents and Settings\Charlie\My Documents\Visual Studio 2010\Projects\echocommandline\Debug\echocommandline.exe
-e
333313.jpg
333313.b64
I suspect the problem would be in the program rather than SystemShellExecute.
Apache OpenOffice 4.1.1
Windows XP
zabolyx
Posts: 216
Joined: Fri Aug 07, 2009 7:28 pm

Re: SystemShellExecute question

Post by zabolyx »

But from the command line I can run it without issues with the above parameters... I'm not sure what would be the problem.

I haven't tried it with merging the files but it should be as follows
Copy CreatedEmail.EML+33331.b64

I'll see if that does anything for me. If not I'm not sure what I can do. I'm trying not to have to create the extra code for using your program.. But I might as well.. you have tested it as working from the ShellExecute? I was kind of looking to avoid having another file to create (the file list file). This program I found does it as a parameter passed to it.

Here is where I snagged it from http://www.fourmilab.ch/webtools/base64/

I liked the idea that I could simply throw it into the loop that get the image file data to attach... With your's I'd have to compile the list of files to convert and then run the program against said list... either way will work in the end.

Our companies development team does have Visual Studio.. so we could compile it on this end if need be, but getting the developers to make minor 5 minute changes to anything seems to take months.
OOo 3.1 On Windows XP SP3 (Home)
Running portables of 2.4, 3.0, 3.1, and 3.2 on XP SP3 (Work)
OOo BASIC user

My contribution to the OOo Community code and more
https://sites.google.com/site/ooomacrolog/
zabolyx
Posts: 216
Joined: Fri Aug 07, 2009 7:28 pm

Re: SystemShellExecute question

Post by zabolyx »

I'm thinking I figured this out...

Shell (either method) doesn't allow for directories with spaces... so trying to point to the files in C:\Documents and Settings\user\desktop\images\ doesn't work.

Since the command prompt starts out in C:\window\openoffice 3\ I need to have it change directory... I figured a way to do this... a tried a true old timer method - the batch file

Using a batch file I can force the command prompt to the correct directory and run the program against the files in the directory from there.

Code: Select all

CD C:\
CD documents and settings
CD username
CD desktop
CD images

base64 -e 333313.jpg 333313.b64
base63 -e 345692.jpg 345692.b64
ect.... 
I can generate this file on the fly and encode them in groups as needed for each email.

Then to try to use the Copy to merge the files. ------- Fingers Crossed
OOo 3.1 On Windows XP SP3 (Home)
Running portables of 2.4, 3.0, 3.1, and 3.2 on XP SP3 (Work)
OOo BASIC user

My contribution to the OOo Community code and more
https://sites.google.com/site/ooomacrolog/
zabolyx
Posts: 216
Joined: Fri Aug 07, 2009 7:28 pm

Re: SystemShellExecute question

Post by zabolyx »

That is working like a charm.
OOo 3.1 On Windows XP SP3 (Home)
Running portables of 2.4, 3.0, 3.1, and 3.2 on XP SP3 (Work)
OOo BASIC user

My contribution to the OOo Community code and more
https://sites.google.com/site/ooomacrolog/
Post Reply