Announcement

Collapse
No announcement yet.

Noob question about shell.execute

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Noob question about shell.execute

    Can a variable be used in the arguments passed to the executable? I have been trying to get a variable that contains the install path to work in the argument passed to the executable. I am having no luck.

  • #2
    Yes, you certainly can pass variables as arguments to Shell.Execute(). Please post the actual code you are executing, so we can see what you are doing, and point out any problems. Use the [CODE]...[/CODE] tags, so the script excerpt is kept as provided, otherwise spaces may be inserted by the forum engine.

    Ulrich

    Comment


    • #3
      What I am trying to do is get the install path from the registry (RegResult) and use it in the Shell.Execute. The DFusionHomePlayer.exe requires the argument for the project path. When executed the DFusionHomePlayer.exe executes but the argument to find the project.dpd file does not work.


      Code:
      RegResult = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\Letters alive TM", "InstallPath", true);
      Shell.Execute(RegResult.."\\Letters Alive\\player\\DFusionHomePlayer.exe", "","\""..RegResult.."-f \\Letters Alive\\Letters Alive\\project.dpd" , RegResult..'"\\Letters Alive\\player\\"', SW_SHOWNORMAL, true);

      Comment


      • #4
        Assuming that the command line should look like this:

        Code:
        "C:\Program Files\ProductName\Letters Alive\player\DFusionHomePlayer.exe" -f "C:\Program Files\ProductName\Letters Alive\Letters Alive\project.dpd"
        then the code you would need should probably be written as this:

        Code:
        RegResult [COLOR="#FF0000"]=[/COLOR] Registry[COLOR="#FF0000"].[/COLOR]GetValue(HKEY_LOCAL_MACHINE[COLOR="#FF0000"],[/COLOR] [COLOR="#800080"]"Software[COLOR="#800080"]\\[/COLOR]Letters alive TM"[/COLOR][COLOR="#FF0000"],[/COLOR] [COLOR="#800080"]"InstallPath"[/COLOR][COLOR="#FF0000"],[/COLOR] [COLOR="#0000FF"]true[/COLOR])[COLOR="#FF0000"];[/COLOR]
        [COLOR="#0000FF"]if[/COLOR] (RegResult [COLOR="#FF0000"]~=[/COLOR] [COLOR="#800080"]""[/COLOR]) [COLOR="#0000FF"]then[/COLOR]
          Shell[COLOR="#FF0000"].[/COLOR]Execute(RegResult [COLOR="#FF0000"]..[/COLOR] [COLOR="#800080"]"[COLOR="#800080"]\\[/COLOR]Letters Alive[COLOR="#800080"]\\[/COLOR]player[COLOR="#800080"]\\[/COLOR]DFusionHomePlayer.exe"[/COLOR][COLOR="#FF0000"],[/COLOR] [COLOR="#800080"]""[/COLOR][COLOR="#FF0000"],[/COLOR] 
            [COLOR="#800080"]"-f [COLOR="#800080"]\"[/COLOR]"[/COLOR] [COLOR="#FF0000"]..[/COLOR] RegResult [COLOR="#FF0000"]..[/COLOR] [COLOR="#800080"]"[COLOR="#800080"]\\[/COLOR]Letters Alive[COLOR="#800080"]\\[/COLOR]Letters Alive[COLOR="#800080"]\\[/COLOR]project.dpd[COLOR="#800080"]\"[/COLOR]"[/COLOR][COLOR="#FF0000"],[/COLOR] 
            RegResult [COLOR="#FF0000"]..[/COLOR] [COLOR="#800080"]"[COLOR="#800080"]\\[/COLOR]Letters Alive[COLOR="#800080"]\\[/COLOR]player[COLOR="#800080"]\\[/COLOR]"[/COLOR][COLOR="#FF0000"],[/COLOR] SW_SHOWNORMAL[COLOR="#FF0000"],[/COLOR] [COLOR="#0000FF"]true[/COLOR])[COLOR="#FF0000"];[/COLOR]
          [COLOR="#0000FF"]error[/COLOR] [COLOR="#FF0000"]=[/COLOR] Application[COLOR="#FF0000"].[/COLOR]GetLastError()[COLOR="#FF0000"];[/COLOR]
          [COLOR="#0000FF"]if[/COLOR] ([COLOR="#0000FF"]error[/COLOR] [COLOR="#FF0000"]~=[/COLOR] [COLOR="#000000"]0[/COLOR]) [COLOR="#0000FF"]then[/COLOR]
            SetupData[COLOR="#FF0000"].[/COLOR]WriteToLogFile([COLOR="#800080"]"Error[COLOR="#800080"]\t[/COLOR][COLOR="#800080"]\t[/COLOR]"[/COLOR] [COLOR="#FF0000"]..[/COLOR] _tblErrorMessages[COLOR="#FF0000"][[/COLOR][COLOR="#0000FF"]error[/COLOR][COLOR="#FF0000"]][/COLOR] [COLOR="#FF0000"]..[/COLOR] [COLOR="#800080"]"[COLOR="#800080"]\r[/COLOR][COLOR="#800080"]\n[/COLOR]"[/COLOR][COLOR="#FF0000"],[/COLOR] [COLOR="#0000FF"]true[/COLOR])[COLOR="#FF0000"];[/COLOR]
          [COLOR="#0000FF"]end[/COLOR]
        [COLOR="#0000FF"]else[/COLOR]
          [COLOR="#0000FF"]error[/COLOR] [COLOR="#FF0000"]=[/COLOR] Application[COLOR="#FF0000"].[/COLOR]GetLastError()[COLOR="#FF0000"];[/COLOR]
          [COLOR="#0000FF"]if[/COLOR] ([COLOR="#0000FF"]error[/COLOR] [COLOR="#FF0000"]~=[/COLOR] [COLOR="#000000"]0[/COLOR]) [COLOR="#0000FF"]then[/COLOR]
            SetupData[COLOR="#FF0000"].[/COLOR]WriteToLogFile([COLOR="#800080"]"Error[COLOR="#800080"]\t[/COLOR][COLOR="#800080"]\t[/COLOR]"[/COLOR] [COLOR="#FF0000"]..[/COLOR] _tblErrorMessages[COLOR="#FF0000"][[/COLOR][COLOR="#0000FF"]error[/COLOR][COLOR="#FF0000"]][/COLOR] [COLOR="#FF0000"]..[/COLOR] [COLOR="#800080"]"[COLOR="#800080"]\r[/COLOR][COLOR="#800080"]\n[/COLOR]"[/COLOR][COLOR="#FF0000"],[/COLOR] [COLOR="#0000FF"]true[/COLOR])[COLOR="#FF0000"];[/COLOR]
          [COLOR="#0000FF"]end[/COLOR]
        [COLOR="#0000FF"]end[/COLOR]
        Please see if this helps.

        Ulrich

        Comment

        Working...
        X