Announcement

Collapse
No announcement yet.

Command Line Argument Needed

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

  • Command Line Argument Needed

    Can I get the command line argument to open a file from a pendrive both at the root level and in a created folder no matter what the drive letter is on the particular machine?

    I am embedding Sumatra portable .pdf viewer as the file to run then I need a particular document to load.

    Thank you.

  • #2
    I mean I need the relative argument for a document to load on the pendrive regardless of the drive letter.. I can get the Sumatra.exe to load. Thank you.

    Comment


    • #3
      When you import a file into your project, it will be placed into the "Docs" sub folder of your "CD_Root\AutoPlay" folder by default. In other words, if both the SumatraPDF program and the document reside in the default folder, you would use an action such as this to open the file:
      Code:
      File.Run("AutoPlay\\Docs\\SumatraPDF.exe", "AutoPlay\\Docs\\mydocument.pdf");
      If everything is on the current drive, then it does not matter which drive letter is was assigned by Windows, as all paths can be relative.

      This is, however, not the only way. You have several global variables and actions at your disposal which you can use to construct a fully qualified path to any folder on the source drive. You have _SourceDrive, _SourceFolder, Folder.GetCurrent(), Folder.SetCurrent(), etc. Check the help file for full details

      Ulrich

      Comment


      • #4
        Thank you. Will this work even if the project is run off a pen drive?

        Comment


        • #5
          I believe I have it. The only other question I would have is can you store the documents outside of being embedded in the compiled program in case there are a lot of them?

          Comment


          • #6
            Hi Miggy7 ,
            I have over 50Gbs of portable apps & software progs on a 64Gb stick Labelled Techtools2 and access them from my compiled AMS file ( 12Mb ).I use the following code in globals

            Code:
            function search_folder()
            drives = Drive.Enumerate();
                for j in pairs(drives) do
                       drive_type = Drive.GetType(drives[j]);
                       if drive_type == 2 or drive_type == 3 then
                           drive_letter = String.Left(drives[j], 1); -- ... takes only the drive letter (without :\)
                           if drive_letter ~= "A" and drive_letter ~= "B" and drive_letter ~= "C" then
                             root_folder_does_exist = Folder.DoesExist(drive_letter..":\\Apps");
                            if root_folder_does_exist then
                                 Current_Serial = Drive.GetInformation(drives[j]).SerialNumber;
                                    Current_Label = Drive.GetInformation(drives[j]).Label;
                                    Current_Name = Drive.GetInformation(drives[j]).DisplayName;
                                    pDrive = drive_letter..":\\"
                                    
                                   end
                               end
                           end    
                     end
                     --Dialog.Message("Notice", Current_Label, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
                     if Current_Label ~="TechTools2" then
                     result = Dialog.Message("Notice", "USB drive not found", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
                    pDrive = ""
                    end
                     end
            accessed on Page1 by:
            Code:
            ------------------------------[[ SCRIPT: Page: Menu, Event: On Preload ]]------------------------------
            search_folder()
            to run a portable or file etc from a button :
            Code:
            ------------------------------[[ SCRIPT: Page: Bios, Object: Button8, Event: On Click ]]------------------------------
            x64 = System.Is64BitOS();
            if x64 then
            Shell.Execute(pDrive.."pApps\\CPU-Z\\cpuz_x64.exe", "open", "", "", SW_SHOWNORMAL, false);
            else
            Shell.Execute(pDrive.."pApps\\CPU-Z\\cpuz_x32.exe", "open", "", "", SW_SHOWNORMAL, false);
            end
            As you can see pDrive is my root and pApps is my portable app folder

            This method has worked for me on any machine running windows
            Cheers

            Comment


            • #7
              What is easy to see by some is difficult by others. Lol.

              This one will take some study and trial and error and maybe 6 months. I really appreciate your time.

              Cup of coffee sent. (theoretically)

              Miggy

              Comment

              Working...
              X
              😀
              🥰
              🤢
              😎
              😡
              👍
              👎