Announcement

Collapse
No announcement yet.

_SourceDrive Issue

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

  • _SourceDrive Issue

    Hi,
    I'm new to AMS and this is my first post so apologise of I'm wrong but I'm sort of getting the hang of it.

    I've got a little issue with having my app running correctly on a USB drive in WinPE. I can get the app to start and run fine but I'm using a script to display some text from a Rich Text file contained on the USB Drive using the '_SourceDrive' variable as part as the path. For example:

    RichText.LoadFromFile("richImageInfo", _SourceDrive.."\\Folder1\Folder2\Richtextfile.rtf

    Am I correct in thinking that '_SourceDrive' is the letter of the drive that the app was run from. For example, if the USB Drive letter was E:\ then '_SourceDrive' is defined as that letter?

    If so then for some reason it's not working. In fact it thinks the '_SourceDrive' is the system drive. In this case, for WinPE, it's X:\. Even if I ran it on a Windows 7 system it defines it as C:\.

    Greatly appreciate any help

  • #2
    Sorry the script is:
    RichText.LoadFromFile("richImageInfo", _SourceDrive.."\\Folder1\\Folder2\\Richtextfile.rt f);

    Comment


    • #3
      I think your problem is here your building it as a webexe so there for it's not going to work, you need to tell it that it's running as a webexe or build it as a hdd build, I don't make webexe's anymore so don't have the code what looks up the true webexe path sorry.
      Plugins or Sources MokoX
      BunnyHop Here

      Comment


      • #4
        Originally posted by kingzooly View Post
        I think your problem is here your building it as a webexe so there for it's not going to work, you need to tell it that it's running as a webexe or build it as a hdd build, I don't make webexe's anymore so don't have the code what looks up the true webexe path sorry.
        Thanks, I suspected that would be the reason. I've just ran it as a HDD Build and it seems to work but now I've got to get it working in WinPE.

        Comment


        • #5
          hi
          kingzooly - don't please do not post rubish of cause you run exe from usb

          G1ggs - you first have to detect your usb drive letter
          Code:
          --###########################################################
          --This code returns Drive info
          --###########################################################
          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..":\\");
                          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;
                                 end
                             end
                         end    
                   end
          Cheers

          Comment


          • #6
            G1ggs This code is put in Globals and called from your script with search_folder()

            Code:
            --###########################################################
            --#This code searches for the required folder (Program Files) in the root directory of every drive of the system
            --#(excluding CD-rom, net drives, and drives A and B);
            --###########################################################
            function search_folder()
                -- Get a list of all drives in the system
                tDrives = Drive.Enumerate();
                
                for j in pairs(tDrives) do
                       nType = Drive.GetType(tDrives[j]); -- for every drive gets its type...
                          
                       if nType == 2 or nType == 3 then --if type is fixed or removable, excluding CD-Rom...
                           sFound_drive_letter = String.Left(tDrives[j], 2); -- gets its drive letter
                           if sFound_drive_letter ~= "A:" and sFound_drive_letter ~= "B:" then -- excludes drives that normally are floppy disks
                               root_folder_does_exist = Folder.DoesExist(sFound_drive_letter.."\\");
                               if root_folder_does_exist then
                                   required_folder = sFound_drive_letter.."\\your folder here";
                                   if Folder.DoesExist (required_folder) == true then
                                       File.OpenURL (required_folder); -- opens the desired folder in that drive (if exists)
                                   end
                            end    
                        end
                       end
                end
            end
            pDrive =r equired_folder
            eg:
            search_folder()
            RichText.LoadFromFile("richImageInfo", pDrive.."\\Folder2\\Richtextfile.rt f);

            Hope this helps
            Cheers

            Comment


            • #7
              The correct way of doing this is by retrieving the contents of the SFXSOURCE: command line parameter. It is in the product documentation.

              Occasionally you may need the location your compressed executable was launched from. For this reason a command line argument is passed into your AutoPlay application in the form: SFXSOURCE:SFE EXE NAME where "SFE EXE NAME" is the full path to the compressed executable. For example, "SFXSOURCE:C:\Temp\launcher.exe". In your AutoPlay application you can access this command line argument using the Global Variable _CommandLineArgs. If any command line arguments are passed to the compressed executable, they will also be passed into the AutoPlay application.
              There no point in using the scripts above, which can return incorrect results.

              Ulrich

              Comment


              • #8
                The correct way of doing this is by retrieving the contents of the SFXSOURCE: command line parameter. It is in the product documentation.
                This cannot be used in "preview" mode, only when your project is compiled and copied to your USB stick, also the "Documentation" does not give example of how to use
                I found this code works well for using SFXSOURCE
                Code:
                --Place in Globals
                --the SFXSOURCE argument is always the last table item so you can access it with Table.Count
                function EXESourceFolder()
                    if _CommandLineArgs[Table.Count(_CommandLineArgs)] then
                        if String.Left(_CommandLineArgs[Table.Count(_CommandLineArgs)], 3) == "SFX" then
                            local strPath = String.Replace(_CommandLineArgs[Table.Count(_CommandLineArgs)], "SFXSOURCE:", "", true)
                            strPath = String.SplitPath(strPath)
                            return strPath.Drive..strPath.Folder
                        end
                    end
                end
                Usage - to trigger code
                Code:
                --Source is your drive letter eg G:\
                Source = EXESourceFolder()
                if Source == "" then
                    Source=_SourceFolder
                end
                Dialog.Message("Notice", "Program running from Drive"..Source, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
                Personally, I prefer to use "Cybergraph's Trusty Code" for running my apps/portable apps from usb stick and I have never had any problems running from any computer,
                I use his code mainly because I change and add progs folders etc and like to preview before compiling

                Comment


                • #9
                  colc speak to me like that ever again and I will just block you, my reply didn't even say anything about USB, There source folder is the temp folder when using the webexe what will create problems later on, also you can make code that will detect if your in a preview or complied work place.

                  Ulrich Your a star I for got what is was called, I going to add that some where maybe in a app I not using but I keep for code snippets.
                  Plugins or Sources MokoX
                  BunnyHop Here

                  Comment


                  • #10
                    kingzooly if you had read the first post correctly before posting
                    I've got a little issue with having my app running correctly on a USB drive in WinPE. I can get the app to start and run fine but I'm using a script to display some text from a Rich Text file contained on the USB Drive
                    I posted the code snippet and Ulrich posted quote from documentation
                    Have a good day

                    Comment


                    • #11
                      Originally posted by colc View Post
                      kingzooly if you had read the first post correctly before posting

                      I posted the code snippet and Ulrich posted quote from documentation
                      Have a good day
                      That sill does not matter yes I messed that but the device or folder you run it from as no impact when it's a webexe unless you have grabbed the commandline infomation like Ulrich said, something that slimped my mind since I no longer make web exe's simple fact of speed, every time you run it, it needs to decomplie.

                      Plugins or Sources MokoX
                      BunnyHop Here

                      Comment

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