How to prevent .exe running on CD or USB port

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prakashsakthivel
    New Member
    • Oct 2007
    • 57

    How to prevent .exe running on CD or USB port

    Hi.

    Exe should run only PC.

    Exe should not run from either CD or USB port.

    Is there a way to check whether it is directory or CD or port?

    Can I use File system object to solve this problem?


    Regards,
    Prakash.s
    Last edited by Killer42; Oct 25 '07, 01:47 AM.
  • shrimant
    New Member
    • Sep 2007
    • 48

    #2
    For CD follow this Microsoft Link:


    For USB follow thia link:

    Get the latest feature info from our tech-obsessed editors with breaking news, in-depth reviews, hands-on videos, and our insights on future products.

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      I think the FileSystemObjec t will tell you a drive type, so you might be able to check that before allowing anything to happen. Specifically, go to your documentation and check out the DriveType property.

      Comment

      • shrimant
        New Member
        • Sep 2007
        • 48

        #4
        Originally posted by Killer42
        I think the FileSystemObjec t will tell you a drive type, so you might be able to check that before allowing anything to happen. Specifically, go to your documentation and check out the DriveType property.
        I did not read the Filesystem Object.....ant thought a diff problem

        Comment

        • kadghar
          Recognized Expert Top Contributor
          • Apr 2007
          • 1302

          #5
          Originally posted by Killer42
          I think the FileSystemObjec t will tell you a drive type, so you might be able to check that before allowing anything to happen. Specifically, go to your documentation and check out the DriveType property.
          But that wont prevent the EXE to be run. That'll only make it stop before it makes anything.

          ... but ignore me, im just suscribing here for interest.

          Comment

          • prakashsakthivel
            New Member
            • Oct 2007
            • 57

            #6
            Originally posted by kadghar
            But that wont prevent the EXE to be run. That'll only make it stop before it makes anything.

            ... but ignore me, im just suscribing here for interest.

            Hi

            I want to stop executing that's all
            that means enough to throw message to user so that user can know
            app is not running in CD or USB Port.


            Regards

            Prakash.S

            Comment

            • 9815402440
              New Member
              • Oct 2007
              • 180

              #7
              HI
              it is very simple
              try to create a text file in app.path at the startup (Use file system object to create file). file name should be greater than 8 chars and it must have atleast a space in it.
              if app.path refers to a cd drive then it will genrate run time error. trap this error and respond the user accordingly.

              if app.path refers a pen drive, there will be no run time error and file system object dont create file on pen drives. now check the existance of the file. if file exists then it is hard drive else it is a flash drive.

              regards
              manpreet singh dhillon hoshiarpur

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                Originally posted by 9815402440
                ... if app.path refers to a cd drive then it will genrate run time error ... file system object dont create file on pen drives ...
                Hang on! Surely you can create a file on a CD drive if the CD is rewritable? And are you saying that the FSO cannot create files on a flash drive? That is certainly news to me!

                Comment

                • 9815402440
                  New Member
                  • Oct 2007
                  • 180

                  #9
                  hi

                  i am very sorry for my last post. i dont know why i wrote that fileSystemObjec t dont create file on pen drive. it may be in hurry.

                  i tried creating file on re-writable cd using FSO. but it genrates an error.

                  sorry once again for the wrong code.

                  regards
                  manpreet singh dhillon hoshiarpur

                  Comment

                  • QVeen72
                    Recognized Expert Top Contributor
                    • Oct 2006
                    • 1445

                    #10
                    Hi,

                    Add Reference "Microsoft Scripting RunTime" to your Project and write this code @ runtime in MDIForm_load:


                    [code=vb]
                    Dim fso As New FileSystemObjec t
                    Dim drv As Object
                    Dim fileType As String
                    Set drv = fso.GetDrive(fs o.GetDriveName( App.Path))
                    fileType = Choose((drv.Dri veType + 1), "Unknown", "Removable" , "Fixed", "Network", "CD-ROM", "RAM Disk")
                    MsgBox fileType
                    Set drv = Nothing
                    Set fso = Nothing

                    [/code]

                    In above code if fileType is not Fixed, then end..


                    Regards
                    Veena

                    Comment

                    • Killer42
                      Recognized Expert Expert
                      • Oct 2006
                      • 8429

                      #11
                      Nice piece of work there, Qveen. Although I don't think fileType is a good name for the result, since it's misleading. Perhaps something like fileLocation would be better.

                      Comment

                      Working...