Help Registry.GetValue to File.Run

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Lewis Arts
    Forum Member
    • Dec 2006
    • 4

    Help Registry.GetValue to File.Run

    Sorry for posting this if it has already been addressed but looked thru 101 pages and may have missed it. This is my first post, I believe in looking and trying to solve the problem and not junking up the forum with repeat Q.

    Know I am doing/missing something but can not figure out what.
    (three days on something this easy is a real waste)

    Software: AutoPlay Media Studio 6.

    Q: Simply trying to read a registry entry and run the program located in the data value.

    REGISTRY:
    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\MyApp]
    "InstallLocation"="D:\\Games\\MyApp\\MyGame.ex e"

    CODE: (Placed On Buttons Click Function)
    _PLAY_GAME = Registry.GetValue(HKEY_LOCAL_MACHINE,"SOFTWARE\\My App","InstallLocation", true);
    File.Run("\"_PLAY_GAME\"", "", "", SW_SHOWNORMAL, false);
    Dialog.Message("Notice", "play_game is:".._PLAY_GAME);

    On Click:
    Dialog Message:
    Window Title: Notice
    Message: play_game is D:\Games\MyApp\MyGame.exe

    File.Run does nothing (At All) but DiaLog.Message returns the right value.

    Any help would be greatly appreciated.
    Thanks in advance.
    Lewis Arts
    Last edited by Lewis Arts; 01-26-2007, 09:15 PM.
  • TJ_Tigger
    Indigo Rose Customer
    • Sep 2002
    • 3159

    #2
    _PLAY_GAME is a variable and should not be inside the quotes

    File.Run(_PLAY_GAME, "", "", SW_SHOWNORMAL, false);

    Try that.

    HTH
    Tigg
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

    Comment

    • Lewis Arts
      Forum Member
      • Dec 2006
      • 4

      #3
      Thanks For the quick reply Tigger.

      Same outcome tho....program will post dialog with the proper address for the file but File.Run does nothing. No error, Not Nothing! Almost like the code is not even there.(but have check it too many times and It Is There) At least with an error I would have some place to start to look.

      don't know any other way to code this, any new Ideas will be greatly appreciated as I can not code the rest of program until this bug is fixed.

      this is my full code for the click function:

      -- result of Registry check is "true" so play the game.
      if App_reg then
      _PLAY_GAME = Registry.GetValue(HKEY_LOCAL_MACHINE,"SOFTWARE\\My App","InstallLocation", true);
      -- File.Run("\"_PLAY_GAME\"", "", "", SW_SHOWNORMAL, false);
      File.Run(_PLAY_GAME, "", "", SW_SHOWNORMAL, false);
      Dialog.Message("Notice", "_PLAY_GAME is:".._PLAY_GAME);

      else
      -- result of Registry check is "false" so install the game.
      Application.Minimize();
      result = File.Run("Autorun\\MyApp_setup.exe", "", "", SW_SHOWNORMAL, true);
      App_reg = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "Software\\My App"); -- check after install to update varible App_reg.
      Application.Restore();
      Page.Redraw();
      end




      Thanks
      Lewis Arts

      Comment

      • mwreyf1
        Indigo Rose Customer
        • Aug 2004
        • 417

        #4
        I tried your code and it works fine here.

        The only thing I can think of is your registry entry is invalid (pointing to file thats not there or a misspelling).

        What is your registry entry (_PLAY_GAME)?

        Comment

        • Lewis Arts
          Forum Member
          • Dec 2006
          • 4

          #5
          Thanks for the help guys.

          I think I found a problem in "Autoplay" itself. The progam I am trying to run, in the register is Four folders(sub keys) deep. (ie..HKEY_LOCAL_MACHINE\SOFTWARE\My App\Games\InstallLocation)

          I found that if I move the registery entery that I populate my variable with up one folder(sub key) it works.

          Looks like it my be a bug an update for "Autoplay" my have to take care of. Never the less, I will have to rebuild my install program to drop a enter one level higher in the registery. Will have to figure out how to do this with out making the registery junky; seeing as I can not go any deeper than one level off SOFTWARE.

          Also for some reason I had to add the "WorkingFolder" or it would try to run the EXE from the location where my program (the one I am working on) is located. (ie.."E:\Program\Autoplay\My App\CDROOT" is where I am building the code at and this is where it will try to run Gamestart.exe instead of from the hard drive)

          **this registry entry does not work!(Go Figure)
          Windows Registry Editor Version 5.00

          [HKEY_LOCAL_MACHINE\SOFTWARE\My App\Darn of War]
          "InstallLocation"="D:\\My App\\Game Data\\Gamestart.exe"
          "InstallFolder"="D:\\My App\\Games\\Game Data"

          **this registry entry DOES work!
          Windows Registry Editor Version 5.00

          [HKEY_LOCAL_MACHINE\SOFTWARE\My App\Darn of War]
          "InstallLocation"="D:\\My App\\Gamestart.exe"
          "InstallFolder"="D:\\My App"

          In this test I DID NOT change any code in the autoplay program just the registry entry part. Both entries are all ready in the windows registry.

          This is all the code in my test program blank page with one button.

          Page Code:
          ON SHOW:
          DOW_reg = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "Software\\THQ\\Dawn of War");

          Button Code:
          ON CLICK:
          if DOW_reg then
          _PLAY_FOLDER = Registry.GetValue(HKEY_LOCAL_MACHINE,"SOFTWARE\\My App","InstallFolder", true);
          _PLAY_GAME = Registry.GetValue(HKEY_LOCAL_MACHINE,"SOFTWARE\\My App","InstallLocation", true);

          File.Run(_PLAY_GAME, "", _PLAY_FOLDER, SW_SHOWNORMAL, false);
          Application.Exit(0);

          else
          -- result of Registry check is "false" so install the game.
          Dialog.Message("Notice", "Game is NOT Installed");
          end

          Comment

          • TJ_Tigger
            Indigo Rose Customer
            • Sep 2002
            • 3159

            #6
            I do not have DOW installed any longer so I tried with another game. This works just fine with WarCraft III. The code below checks for one version of the game and if not found then the older version.

            Code:
            if Registry.DoesKeyExist(HKEY_CURRENT_USER, "Software\\Blizzard Entertainment\\Warcraft III") then
            	--checks for frozen throne
            	_PLAY_GAME = Registry.GetValue(HKEY_CURRENT_USER, "Software\\Blizzard Entertainment\\Warcraft III","ProgramX", true);
            	if _PLAY_GAME == "" then
            		--if no frozen throne then checks for WCIII
            		_PLAY_GAME = Registry.GetValue(HKEY_CURRENT_USER, "Software\\Blizzard Entertainment\\Warcraft III","Program", true);
            	end
            	
            	if _PLAY_GAME == "" then
            		Dialog.Message("ERROR", "Error retrieving path to game");
            	else
            		File.Run(_PLAY_GAME, "", "", SW_SHOWNORMAL, false);
            	end
            
            else
            	-- result of Registry check is "false" so install the game.
            	Dialog.Message("Notice", "Game is NOT Installed");
            end
            Also when you complain about a bug being in the program it is customary to provide the version of the program that you are using. The current version is 6.0.4.0 and the above code works with that. Make sure you are on the latest version of AMS.

            Also if you still have problems with your project you can send it to me (contact me via PM) and I will install DOW and test it here.

            Cheers
            Tigg
            TJ-Tigger
            "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
            "Draco dormiens nunquam titillandus."
            Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

            Comment

            Working...
            X