Announcement

Collapse
No announcement yet.

Cmd command

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

  • Cmd command

    I am trying to run the hide command for a folder. I am aware of the hide options that setup factory includes but that is easily figured out. This method is a bit tougher and is for our security so not with the main files location.

    I really need help as i can't figure out how to write to the CMD. I am trying to open CMD then execute but not sure how.

    The standard method is you add to cmd that i want is
    Code:
    attrib +s +h
    plus the directory. So in my case i can use the %AppFolder% + the folder directory.

    i tried some advice from this forum to just use a batch to exe type method. But i don't always know the location and hard to setup that way. Much easier to execute the command through the CMD.

    Code:
    File.Run(_WindowsFolder.."attrib +s +h %AppFolder%".."\\Official\\", "C:\\WINDOWS\\system32", SW_SHOWNORMAL, true);
    Please help!!!

  • #2
    File.SetAttributes() allows you to perform the exact same action without the need to run an external command. That is what you should use.

    If you still feel that you need to run the external command for any reason, please refer to the product documentation - your syntax is completely wrong. You need to understand what a filename is (hint: it ends with ".exe"), and what arguments are. You are also not expanding the session variable, so there is no way your script will work as expected:

    Click image for larger version

Name:	SCRN-2022-04-16-01.png
Views:	112
Size:	43.6 KB
ID:	308655

    This might work better, but again, no need at all for this when you have built-in actions exactly for this purpose.
    Code:
    File.Run(_WindowsFolder.."\\attrib.exe", "+s +h " .. SessionVar.Expand("\"%AppFolder%\\Official\"\\"), "", SW_SHOWNORMAL, true);
    Ulrich

    Comment


    • #3
      Will try it out. The built in mode only hides the standard hidden files not the super hidden which is the windows system files.

      Comment


      • #4
        oh i see the File.SetAttributes() instead of the File.Run() and it does not need the external cmd. Ok that sounds good. I have never used this before. Thanks.

        I was expanding the session variable for other tests. But i shared this example i found and did not catch the mistake. I think the reason i shared this example was because this was a sample i found on the forums. But yes i always check the samples in the documentation and i really like the documentation as well. There are 2 methods that work for expanding the %AppFolder% session variable.

        Lets see if i can now get this working. Thanks Ulrich....

        Comment


        • #5
          Is the File.SetAttributes() the same as the attributes in the folder options? Then this hidden is not as god as the one i am trying. Not much better but many are not aware of it.

          By the way i could not get the File.SetAttributes() to work. I placed this code in the on pre load section. The file New.txt would show up but not hidden,
          Code:
          -- create an empty table
          attrib = {};
          
          -- add two elements to it ("ReadOnly" and "Hidden")
          attrib.ReadOnly = true;
          attrib.Hidden = true;
          
          File.SetAttributes(_TempFolder .. "\\New.txt", attrib );

          I prefer to use to use the method in this image. Can you help me again. The code you shared did not work.


          Comment


          • #6
            This should hide the folder Official. How can we do the same as this cmd code as when entered in cmd it works. We need to place the file first then run this code after install.
            Code:
            File.Run(_WindowsFolder.."\\attrib.exe", "+s +h " .. SessionVar.Expand("\"%AppFolder%\\Official\"\\"), "", SW_SHOWNORMAL, true);

            Comment


            • #7
              Ulrich i know what a file name is. See image. Do we need the exe for attrib ?

              Comment


              • #8
                Originally posted by DevoTaylor View Post
                Ulrich i know what a file name is. See image. Do we need the exe for attrib ?
                I posted working code. Of course you need to provide the ".exe", or it won't work.

                Ulrich

                Comment

                Working...
                X