Applies To: |
|
Summary: |
Question: I have a some shortcuts which I
want to execute, but nothing seems to happen. My Cicode looks like
the following:
FUNCTION Why does Exec() return 272, "Out of Memory", and not run my Shortcut? |
Solution: |
Citect attempts to execute this as a
program. Unfortunately, the Exec CiCode function does not know
about the new shell functionality that exists in Windows 95 and NT
4.0. The solution is to use the "start" command which is part of
Windows 95 and NT 4.0, but has different syntax for each. (The
"start" command must be in your path for Windows 95; usually
c:\windows\command. "start" is part of the shell in Windows NT
4.0.). The CiCode below shows how to use the "start" command for
both Window NT 4.0 and Windows 95:
See Q4572 "Opening Applications, Documents, Folders, Shortcuts, or Web Pages from CitectSCADA" for an alternate method that does not require opening a DOS window to execute the command. FUNCTION The first set of quotes following the start command are required as the command allows for a window title to be specified. Additional options are available for specifying a starting directory and various window and memory directives. For more information on the use of the "start" command, type "start /?" at the command prompt. When the CiCode function is called, the "start" command is run which knows about shell associations. This has the added advantage in that Citect can call an Excel spreadsheet directly without needing to know where the Excel Program resides. The disadvantage with this, is that Exec() will return no error if a file cannot be opened, only if the "start" command cannot be run. The "start" command opens a command prompt on Windows 95 for a few seconds that may look unsightly. Use mode 6 to minimise the command prompt box so that this is not noticeable, once you are happy that the shortcut is being executed. NOTE: When opening a file on Windows95 and NT, which has either a long filename with spaces or a path with spaces the ^" characters must be used on either side of the command to execute. For example: Exec("start ^"^" c:\Program Files\MyShortCuts\MyProgram.lnk"); will NOT work as it cannot work out what TO DO with the space in "Program Files", however, Exec("start ^"^" ^"c:\Program Files\MyShortCuts\MyProgram.lnk^""); works as required. |
Keywords: |
Related Links
Attachments