PDA

View Full Version : About Shell.Execute



qiuwen777
12-16-2004, 02:13 AM
I want to register an OCX after install,so I write the script like that
Shell.Execute("%SystemFolder%//regsvr32","OPEN","%AppFolder%//ocx//a.ocx")
but it don't recognize the "%AppFolder%//ocx//a.ocx".because the %AppFoler% now is "c:\program files",
so what can i do ?
I tried using the sessionvar.expand,but I failed.

best regard.

atrust
12-16-2004, 05:37 AM
Variables have to be expanded first,
http://support.indigorose.com/index.php?_a=knowledgebase&_j=questiondetails&_i=261&nav2=Setup%20Factory%207.0
I hope this would help.

Adam
12-16-2004, 08:17 AM
qiuwen777,

Try something like this:

RegSvr = SessionVar.Expand("%SystemFolder%\\regsvr32.exe");
F_Name = SessionVar.Expand("%AppFolder%\\ocx\\a.ocx");

Shell.Execute(RegSvr,"OPEN",F_Name);

Or you can perform the expand option within the action like this:

Shell.Execute(SessionVar.Expand("%SystemFolder%\\regsvr32.exe"),"OPEN",SessionVar.Expand("%AppFolder%\\ocx\\a.ocx"));

But I think the first method is more readable to the developer.

Adam Kapilik

qiuwen777
12-16-2004, 08:34 PM
Adam

I just tried like that

RegSvr = SessionVar.Expand("%SystemFolder%\\regsvr32.exe");
F_Name = SessionVar.Expand("%AppFolder%\\ocx\\a.ocx");

Shell.Execute(RegSvr,"OPEN",F_Name);

but error

" Argument 3 must be of type string "

so how to ?

thank you.

Adam
12-17-2004, 12:20 PM
I just tested this exact code:

RegSvr = SessionVar.Expand("%SystemFolder%\\regsvr32.exe");
F_Name = SessionVar.Expand("%AppFolder%\\ocx\\a.ocx");

Shell.Execute(RegSvr, "open", F_Name, "");

And it seems to be calling regsvr32.exe properly.

Adam Kapilik

Ted Sullivan
12-17-2004, 12:38 PM
Yes - double check what you've typed there. If it still doesn't work, copy and paste the exact script here onto the forum so we can see what is going on.

It sounds like a typo on your side.

qiuwen777
12-19-2004, 12:13 AM
I'm sorry to bother you again.but it still don't work properly.So I came here again.

I have checked my script again,and just use Adam's code.

RegSvr = SessionVar.Expand("%SystemFolder%\\regsvr32.exe");
F_Name = SessionVar.Expand("%AppFolder%\\CoolButton.ocx");

Shell.Execute(RegSvr,"OPEN",F_Name);

There ,F_Name is "C:\Program Files\CoolButton.ocx",

when Regsvr32 are registering, an error occured,because regsvr32 can't find the properly module "c:\program"

I guest maybe F_NAME contain a blank char,that it isn't recognized properly,
so I just use the Code like below

Shell.Execute(RegSvr,"OPEN","C:\Program Files\CoolButton.ocx");

The same error occured.

thank you .Wish to get your help.

PS,my OS is WinXp Pro(Simplified Chinese).

Ted Sullivan
12-19-2004, 10:25 AM
Try this line instead:

Shell.Execute(RegSvr,"OPEN","C:\\Program Files\\CoolButton.ocx");

qiuwen777
12-19-2004, 06:07 PM
I just used again.

Failed again.

Waza04
12-20-2004, 01:21 AM
I just used again.

Failed again.

Can't you use Setup Factory's internal action of "Register DLL"? It should work with OCX's too...

qiuwen777
12-26-2004, 07:01 PM
Can't you use Setup Factory's internal action of "Register DLL"? It should work with OCX's too...

I can't do that like what you said,because the ocx file is dependent on other files.