Shell Command with warning message

utouto Member Posts: 36
Dear All,

Regarding to the shell command which execute the external application.

SHELL('C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE');

But I really confused about the warning message which display when shell command will be called.
The warning message is...

"You are about to run the following executeable for the first time:
Executable:C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE
Parameter:
Please be aware that you may be running an executable that could potentially harm your computer.
Do you trust this executable and its parameter?"

I knows it will be display only at the first time, but I don't want it pop up anyway. How can I blocked this warnig message?????

Thank you in advance.

Comments

  • toennetoenne Member Posts: 38
    hi uto,

    i found no way to solve this problem directly. the used commands are recorded in the zup-file, every command that is commited will not produce a warning until you delete the zup-file.

    the problem increases if you work with varying parameters, e.g. doc names for word. the warning will appear once for every new shell string and client.

    we did a workaround by using an ocx, which reveices and executes the command. :?
  • toennetoenne Member Posts: 38
    hi again,

    maybe you can download it from here on monday (depending on the velocity of our best webmaster).

    the download is named "oyster". (it all tasts like shells :D )
  • janpieterjanpieter Member Posts: 298
    Hi

    Dont know why this 1-time message bothers you but well here is a way to circumvent, create this function in Navision and use it instead of the standard shell function:
    MyShell(Application : Text[1024])
    CREATE(lclsShell);
    lclsShell.Run(Application);
    CLEAR(lclsShell);
    

    lclsShell is a local variable of type automation and subtype 'Windows Script Host Object Model'.WshShell

    Jan-Pieter
    In a world without Borders or Fences, who needs Windows and Gates?
  • utouto Member Posts: 36
    Hi Toene & Janpieter

    Thank you for your help. But I still stucked in this problem. I'm waiting for your OCX , Toene. And I had tried to code follow Janpieter's sample, but it's not work properly. Maybe it is my misunderstand. :cry: Janpieter , can u explain me for more details?

    MyShell(RunApplication : Text[1024])
    CREATE(lclsShell);
    lclsShell.Run(RunApplication);
    CLEAR(lclsShell);

    This is the function which created in the codeunit and the function is called by the command button (on form). When I press the button , it will displayed the following error message :

    "This message is for C/AL programmers:

    An exception was raised in method run. The OLE controls or Automation server has returned error(HRESULT) -2147352567.
    The component did not provide the exception description."

    So what is my misunderstand? ](*,) Please suggest.
  • toennetoenne Member Posts: 38
    if you send me an email with your email address, i'll send the ocx. i did upload it, but it hasn't appeared yet.
  • janpieterjanpieter Member Posts: 298
    dont know what is going wrong.

    For example i can use:
    MyShell('NotePad.exe');
    

    and this works fine.

    Maybe you must experiment with other applications (it may be the application you use causing an error). Also look at how you use slashes and if the path excist etcetera.
    In a world without Borders or Fences, who needs Windows and Gates?
  • utouto Member Posts: 36
    Hi

    First , I wanna say "Thank you" to you all.

    I had tried for every suggestion. First , I tried to code follow Janpieter's suggest. I found something!!! #-o It's works propery for the short path parameter. Coz I tried to execute the application which stored in the "c:\front" and it's works. But for the same application which stored in the other folder (eg. "C:\Program Files\Microsoft Business Solutions-Navision\Front" ) It's still pop up the error msg as I told you. Then I tried to use the ocx's tonne , and now it's works propery for all paths. \:D/

    Thank you, Janpieter & Tonne. =D>

    uto
  • TorbenTorben Member Posts: 21
    Hi all
    May I add that perhaps the error message has nothing to do with Navision, but may come from firewall or virus protection programs running on the same system. :-k

    Best Rgds
    Torben
  • bestianhowbestianhow Member Posts: 120
    Hi uto, u can try coding below. But i don't whether work for u?


    Pls define a automation variable called "laum_Shell",
    Datatype = Automation
    SubType = 'Microsoft Shell Controls And Automation'.Shell


    Coding
    =====
    CREATE(laum_Shell);
    laum_Shell.Open('C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE');
    CLEAR(laum_Shell);
  • utouto Member Posts: 36
    Hi all,

    Thank you for your help. I had tried to do follow bestianhow's code and it's works fine. I don't need to remove the execute to the others folder and regist the ocx. I think the customer should prefer this solution. (I also because it can reduce my works :lol: )
    B.T.W. I think all solutions are good for the different situation. No one is the best but all are good.

    Thank you for your helps. =D> =D> =D>

    Uto
  • HMRHMR Member Posts: 5
    Hi

    The Code from bestianhow works fine but i have a problem with parameters after the exe.
    It doesn't run.

    Can everybody help.


    HMR
  • SchwarzSchwarz Member Posts: 8
    Hello,

    i find the follwoing note in the Late Changes documentation of Navision 4.0.
    ***

    C/SIDE
    The following changes have been made in C/SIDE:
    SHELL Function
    You use this C/AL function to execute external programs and operating
    system commands.
    The syntax for this function is:
    [ReturnCode]:= SHELL(Name [, Param, ...])
    In previous versions of Navision, you could pass the parameter(s) as part
    of the Name argument – for example,
    SHELL(“C:\Windows\Notepad.exe MyFile.txt”)
    In Navision 4.0, you can no longer pass the parameter as part of the Name
    argument. The name argument must be filled in and it must not contain
    any parameters except for the executable. The parameter information must
    now be hard coded into the system as a text constant or as a variable.
    The SHELL function has been redesigned so that each user can create a
    list of trusted executables. This list is maintained in the user’s zup file. The
    way this function works depends on whether the executable is given as a
    text constant or as a variable.
    Text Constant
    If the name of the executable is passed to the SHELL function as a text
    constant the executable is trusted and the user is not prompted to confirm
    that they trust the executable. This is also the case when the executable
    (text constant) is called with a number of other arguments that have been
    assigned manually.
    Variable
    If the name of the executable is passed to the SHELL function as a
    variable the executable is not trusted and the user is prompted to confirm
    whether or not they trust the executable the first time it is called. Once the
    user has confirmed that they trust the executable it can be called again at
    any time without their having to confirm that they trust it.
    ***

    Hope this helps solving the problem.
  • HMRHMR Member Posts: 5
    Hi,

    thank you for your Message :) .

    Can i eliminate the message "run at first time" ?.

    Every parameters to send with the exe are different.

    It's nerves every time to close the Message.


    Can everybody help.


    HMR
  • aodaod Member Posts: 54
    edited 2005-11-16
    I have the same Problem - does anyboday have an solution ???

    Hello HMR,

    I had the same situation : Executing external Programs with different Parameters - and I solved it using "Oyster" from the Download-section
  • ajhvdbajhvdb Member Posts: 672
    Can't you use the suggestion of janpieter?
  • JanVJanV Member Posts: 34
    Another way you could use is the "Hyperlink"-Function.
    hyperlink('C:\worddoc.doc');
    

    The only thing is, that a the filetype has to be registered with some program.
  • JanVJanV Member Posts: 34
    Oh, I just read in a different topic that the Hyperlink-Function somehow doesn't work anymore in 4.0 (which would explain why anyone uses this shitty Shell-command :D ).

    Ok, so then my suggestion is to use an automation-variable. Three lines of code no security restrictions (as far as I know).
  • Alex_ChowAlex_Chow Member Posts: 5,063
    bestianhow wrote:
    Hi uto, u can try coding below. But i don't whether work for u?


    Pls define a automation variable called "laum_Shell",
    Datatype = Automation
    SubType = 'Microsoft Shell Controls And Automation'.Shell


    Coding
    =====
    CREATE(laum_Shell);
    laum_Shell.Open('C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE');
    CLEAR(laum_Shell);

    Beautiful!!! Thank you!
  • SavatageSavatage Member Posts: 7,142
    I guess nobody likes the PushAction, RunSystem, RunCommand properties anymore :(
Sign In or Register to comment.