Killing a MDB file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Atley

    Killing a MDB file

    I am trying to make sure that an MDB is not in use and then delete it. If
    it is in use, I want to automatically disconnect all the users and then
    delete the file.

    Any suggestions are welcome.



  • Armin Zingler

    #2
    Re: Killing a MDB file

    "Atley" <atley_1@hotmai l.com> schrieb[color=blue]
    > I am trying to make sure that an MDB is not in use and then delete
    > it. If it is in use, I want to automatically disconnect all the
    > users and then delete the file.[/color]

    You can not disconnect the users. They have to close the file.


    --
    Armin

    How to quote and why:



    Comment

    • Barry

      #3
      Re: Killing a MDB file

      We have had success using the NetFileClose API. This has the effect
      of unlocking the file. But it doesn't tell you if the MDB is in use.

      We have a time window and anybody on after that time window can be
      disconnected from the MDB at any time.

      We have only run it when the mdb is on a server (w2000 but the docs
      say it will work on an NT server) and the account running the
      NetFileClose is an "operator" on the server.

      Notice that the API expects a Unicode string for the servername so the
      normal call of (byval str as string) did not work for us.

      Public Declare Function NetFileClose lib "netapi32.d ll" _
      (bvay lpstr as long, byval dword as long) as long

      We call it this way

      lngreturned = NetFileClose(St rPtr(filename), fileId)

      Now the fileid must be obtained from NetFileEenum API and that is not
      for the faint of heart.

      Before I try to post some code ( I'll have to trim it some since we
      have some misc debugging code in here)... Is this something that you
      want to get into? I don't know of any other way to kick users out of
      a file.

      In order to check on whether or not users are really using the MDB
      file, I guess you would have to watch the file and check to see if it
      was modified in the past X minutes (or set up a FileSystemWatch er
      rahter than use the API calls) !!


      On Fri, 30 Jan 2004 20:44:31 +0100, "Armin Zingler"
      <az.nospam@free net.de> wrote:
      [color=blue]
      >"Atley" <atley_1@hotmai l.com> schrieb[color=green]
      >> I am trying to make sure that an MDB is not in use and then delete
      >> it. If it is in use, I want to automatically disconnect all the
      >> users and then delete the file.[/color]
      >
      >You can not disconnect the users. They have to close the file.[/color]

      bceggersATcomca stDOTnet

      Comment

      • Atley

        #4
        Re: Killing a MDB file

        YES PLEASE....

        This problem has been a pain in our butts for over a week now... Please
        post..


        Atley



        "Barry" <bceggers@comca st.net> wrote in message
        news:pouo10h8k2 7ggl8p4stu7cq4u k4sfj80sj@4ax.c om...[color=blue]
        > We have had success using the NetFileClose API. This has the effect
        > of unlocking the file. But it doesn't tell you if the MDB is in use.
        >
        > We have a time window and anybody on after that time window can be
        > disconnected from the MDB at any time.
        >
        > We have only run it when the mdb is on a server (w2000 but the docs
        > say it will work on an NT server) and the account running the
        > NetFileClose is an "operator" on the server.
        >
        > Notice that the API expects a Unicode string for the servername so the
        > normal call of (byval str as string) did not work for us.
        >
        > Public Declare Function NetFileClose lib "netapi32.d ll" _
        > (bvay lpstr as long, byval dword as long) as long
        >
        > We call it this way
        >
        > lngreturned = NetFileClose(St rPtr(filename), fileId)
        >
        > Now the fileid must be obtained from NetFileEenum API and that is not
        > for the faint of heart.
        >
        > Before I try to post some code ( I'll have to trim it some since we
        > have some misc debugging code in here)... Is this something that you
        > want to get into? I don't know of any other way to kick users out of
        > a file.
        >
        > In order to check on whether or not users are really using the MDB
        > file, I guess you would have to watch the file and check to see if it
        > was modified in the past X minutes (or set up a FileSystemWatch er
        > rahter than use the API calls) !!
        >
        >
        > On Fri, 30 Jan 2004 20:44:31 +0100, "Armin Zingler"
        > <az.nospam@free net.de> wrote:
        >[color=green]
        > >"Atley" <atley_1@hotmai l.com> schrieb[color=darkred]
        > >> I am trying to make sure that an MDB is not in use and then delete
        > >> it. If it is in use, I want to automatically disconnect all the
        > >> users and then delete the file.[/color]
        > >
        > >You can not disconnect the users. They have to close the file.[/color]
        >
        > bceggersATcomca stDOTnet[/color]


        Comment

        • Barry

          #5
          Re: Killing a MDB file

          Rather than try to post it all here, see if you can get this zip file



          When you run the project, just enter the servername, click on "find
          locked files", select a file from the list box and then click on
          "unlock selected file" and that should do it for unlocking the file.

          Sorry about the choppy-ness of the code but i removed a lot of
          debugging code. The tough part is where the CopyMemory is used to
          grab selected information that is returned from some of the API calls
          (we didn't need it all).

          If you have any questions, let me know and I'll see what I can do.

          Barry
          bceggersATcomca stDOTnet


          On Mon, 2 Feb 2004 08:17:43 -0500, "Atley" <atley_1@hotmai l.com>
          wrote:
          [color=blue]
          >YES PLEASE....
          >
          >This problem has been a pain in our butts for over a week now... Please
          >post..
          >
          >
          >Atley
          >
          >
          >
          >"Barry" <bceggers@comca st.net> wrote in message
          >news:pouo10h8k 27ggl8p4stu7cq4 uk4sfj80sj@4ax. com...[color=green]
          >> We have had success using the NetFileClose API. This has the effect
          >> of unlocking the file. But it doesn't tell you if the MDB is in use.
          >>
          >> We have a time window and anybody on after that time window can be
          >> disconnected from the MDB at any time.
          >>
          >> We have only run it when the mdb is on a server (w2000 but the docs
          >> say it will work on an NT server) and the account running the
          >> NetFileClose is an "operator" on the server.
          >>
          >> Notice that the API expects a Unicode string for the servername so the
          >> normal call of (byval str as string) did not work for us.
          >>
          >> Public Declare Function NetFileClose lib "netapi32.d ll" _
          >> (bvay lpstr as long, byval dword as long) as long
          >>
          >> We call it this way
          >>
          >> lngreturned = NetFileClose(St rPtr(filename), fileId)
          >>
          >> Now the fileid must be obtained from NetFileEenum API and that is not
          >> for the faint of heart.
          >>
          >> Before I try to post some code ( I'll have to trim it some since we
          >> have some misc debugging code in here)... Is this something that you
          >> want to get into? I don't know of any other way to kick users out of
          >> a file.
          >>
          >> In order to check on whether or not users are really using the MDB
          >> file, I guess you would have to watch the file and check to see if it
          >> was modified in the past X minutes (or set up a FileSystemWatch er
          >> rahter than use the API calls) !!
          >>
          >>
          >> On Fri, 30 Jan 2004 20:44:31 +0100, "Armin Zingler"
          >> <az.nospam@free net.de> wrote:
          >>[color=darkred]
          >> >"Atley" <atley_1@hotmai l.com> schrieb
          >> >> I am trying to make sure that an MDB is not in use and then delete
          >> >> it. If it is in use, I want to automatically disconnect all the
          >> >> users and then delete the file.
          >> >
          >> >You can not disconnect the users. They have to close the file.[/color]
          >>
          >> bceggersATcomca stDOTnet[/color]
          >[/color]

          bceggersATcomca stDOTnet

          Comment

          • Atley

            #6
            Re: Killing a MDB file

            I tried the code, but even after unlocking the file I cannot delete it
            through explorer. Is there something else I have to do to make it so I can
            kill this MDB file?

            Atley



            "Barry" <bceggers@castc om.com> wrote in message
            news:vdau10ddj4 cr8p9nf5s3i6uks k0am0dtc9@4ax.c om...[color=blue]
            > Rather than try to post it all here, see if you can get this zip file
            >
            > http://home.comcast.net/~bceggers/do...nlockfiles.zip
            >
            > When you run the project, just enter the servername, click on "find
            > locked files", select a file from the list box and then click on
            > "unlock selected file" and that should do it for unlocking the file.
            >
            > Sorry about the choppy-ness of the code but i removed a lot of
            > debugging code. The tough part is where the CopyMemory is used to
            > grab selected information that is returned from some of the API calls
            > (we didn't need it all).
            >
            > If you have any questions, let me know and I'll see what I can do.
            >
            > Barry
            > bceggersATcomca stDOTnet
            >
            >
            > On Mon, 2 Feb 2004 08:17:43 -0500, "Atley" <atley_1@hotmai l.com>
            > wrote:
            >[color=green]
            > >YES PLEASE....
            > >
            > >This problem has been a pain in our butts for over a week now... Please
            > >post..
            > >
            > >
            > >Atley
            > >
            > >
            > >
            > >"Barry" <bceggers@comca st.net> wrote in message
            > >news:pouo10h8k 27ggl8p4stu7cq4 uk4sfj80sj@4ax. com...[color=darkred]
            > >> We have had success using the NetFileClose API. This has the effect
            > >> of unlocking the file. But it doesn't tell you if the MDB is in use.
            > >>
            > >> We have a time window and anybody on after that time window can be
            > >> disconnected from the MDB at any time.
            > >>
            > >> We have only run it when the mdb is on a server (w2000 but the docs
            > >> say it will work on an NT server) and the account running the
            > >> NetFileClose is an "operator" on the server.
            > >>
            > >> Notice that the API expects a Unicode string for the servername so the
            > >> normal call of (byval str as string) did not work for us.
            > >>
            > >> Public Declare Function NetFileClose lib "netapi32.d ll" _
            > >> (bvay lpstr as long, byval dword as long) as long
            > >>
            > >> We call it this way
            > >>
            > >> lngreturned = NetFileClose(St rPtr(filename), fileId)
            > >>
            > >> Now the fileid must be obtained from NetFileEenum API and that is not
            > >> for the faint of heart.
            > >>
            > >> Before I try to post some code ( I'll have to trim it some since we
            > >> have some misc debugging code in here)... Is this something that you
            > >> want to get into? I don't know of any other way to kick users out of
            > >> a file.
            > >>
            > >> In order to check on whether or not users are really using the MDB
            > >> file, I guess you would have to watch the file and check to see if it
            > >> was modified in the past X minutes (or set up a FileSystemWatch er
            > >> rahter than use the API calls) !!
            > >>
            > >>
            > >> On Fri, 30 Jan 2004 20:44:31 +0100, "Armin Zingler"
            > >> <az.nospam@free net.de> wrote:
            > >>
            > >> >"Atley" <atley_1@hotmai l.com> schrieb
            > >> >> I am trying to make sure that an MDB is not in use and then delete
            > >> >> it. If it is in use, I want to automatically disconnect all the
            > >> >> users and then delete the file.
            > >> >
            > >> >You can not disconnect the users. They have to close the file.
            > >>
            > >> bceggersATcomca stDOTnet[/color]
            > >[/color]
            >
            > bceggersATcomca stDOTnet[/color]


            Comment

            • Barry

              #7
              Re: Killing a MDB file

              What is the OS of the server with the locked file?
              Is the file in a public share?
              What are the permissions for your account (admin,operator ,power user,
              etc)?
              Do you have delete rights to that folder and file (when unlocked) ?

              Barry

              On Tue, 3 Feb 2004 08:37:40 -0500, "Atley" <atley_1@hotmai l.com>
              wrote:
              [color=blue]
              >I tried the code, but even after unlocking the file I cannot delete it
              >through explorer. Is there something else I have to do to make it so I can
              >kill this MDB file?
              >
              >Atley
              >
              >
              >
              >"Barry" <bceggers@castc om.com> wrote in message
              >news:vdau10ddj 4cr8p9nf5s3i6uk sk0am0dtc9@4ax. com...[color=green]
              >> Rather than try to post it all here, see if you can get this zip file
              >>
              >> http://home.comcast.net/~bceggers/do...nlockfiles.zip
              >>
              >> When you run the project, just enter the servername, click on "find
              >> locked files", select a file from the list box and then click on
              >> "unlock selected file" and that should do it for unlocking the file.
              >>
              >> Sorry about the choppy-ness of the code but i removed a lot of
              >> debugging code. The tough part is where the CopyMemory is used to
              >> grab selected information that is returned from some of the API calls
              >> (we didn't need it all).
              >>
              >> If you have any questions, let me know and I'll see what I can do.
              >>
              >> Barry
              >> bceggersATcomca stDOTnet
              >>
              >>
              >> On Mon, 2 Feb 2004 08:17:43 -0500, "Atley" <atley_1@hotmai l.com>
              >> wrote:
              >>[color=darkred]
              >> >YES PLEASE....
              >> >
              >> >This problem has been a pain in our butts for over a week now... Please
              >> >post..
              >> >
              >> >
              >> >Atley
              >> >
              >> >
              >> >
              >> >"Barry" <bceggers@comca st.net> wrote in message
              >> >news:pouo10h8k 27ggl8p4stu7cq4 uk4sfj80sj@4ax. com...
              >> >> We have had success using the NetFileClose API. This has the effect
              >> >> of unlocking the file. But it doesn't tell you if the MDB is in use.
              >> >>
              >> >> We have a time window and anybody on after that time window can be
              >> >> disconnected from the MDB at any time.
              >> >>
              >> >> We have only run it when the mdb is on a server (w2000 but the docs
              >> >> say it will work on an NT server) and the account running the
              >> >> NetFileClose is an "operator" on the server.
              >> >>
              >> >> Notice that the API expects a Unicode string for the servername so the
              >> >> normal call of (byval str as string) did not work for us.
              >> >>
              >> >> Public Declare Function NetFileClose lib "netapi32.d ll" _
              >> >> (bvay lpstr as long, byval dword as long) as long
              >> >>
              >> >> We call it this way
              >> >>
              >> >> lngreturned = NetFileClose(St rPtr(filename), fileId)
              >> >>
              >> >> Now the fileid must be obtained from NetFileEenum API and that is not
              >> >> for the faint of heart.
              >> >>
              >> >> Before I try to post some code ( I'll have to trim it some since we
              >> >> have some misc debugging code in here)... Is this something that you
              >> >> want to get into? I don't know of any other way to kick users out of
              >> >> a file.
              >> >>
              >> >> In order to check on whether or not users are really using the MDB
              >> >> file, I guess you would have to watch the file and check to see if it
              >> >> was modified in the past X minutes (or set up a FileSystemWatch er
              >> >> rahter than use the API calls) !!
              >> >>
              >> >>
              >> >> On Fri, 30 Jan 2004 20:44:31 +0100, "Armin Zingler"
              >> >> <az.nospam@free net.de> wrote:
              >> >>
              >> >> >"Atley" <atley_1@hotmai l.com> schrieb
              >> >> >> I am trying to make sure that an MDB is not in use and then delete
              >> >> >> it. If it is in use, I want to automatically disconnect all the
              >> >> >> users and then delete the file.
              >> >> >
              >> >> >You can not disconnect the users. They have to close the file.
              >> >>
              >> >> bceggersATcomca stDOTnet
              >> >[/color]
              >>
              >> bceggersATcomca stDOTnet[/color]
              >[/color]

              bceggersATcomca stDOTnet

              Comment

              • Atley

                #8
                Re: Killing a MDB file

                > What is the OS of the server with the locked file?
                Windows 2000 Server
                [color=blue]
                > Is the file in a public share?[/color]
                Yes
                [color=blue]
                > What are the permissions for your account (admin,operator ,power user,
                > etc)?[/color]
                Domain Admin
                [color=blue]
                > Do you have delete rights to that folder and file (when unlocked) ?[/color]
                Yes



                "Barry" <bceggers@castc om.com> wrote in message
                news:9pc020dqlc q0vhl674c3af52q 5ed0fbbou@4ax.c om...[color=blue]
                > What is the OS of the server with the locked file?
                > Is the file in a public share?
                > What are the permissions for your account (admin,operator ,power user,
                > etc)?
                > Do you have delete rights to that folder and file (when unlocked) ?
                >
                > Barry
                >
                > On Tue, 3 Feb 2004 08:37:40 -0500, "Atley" <atley_1@hotmai l.com>
                > wrote:
                >[color=green]
                > >I tried the code, but even after unlocking the file I cannot delete it
                > >through explorer. Is there something else I have to do to make it so I[/color][/color]
                can[color=blue][color=green]
                > >kill this MDB file?
                > >
                > >Atley
                > >
                > >
                > >
                > >"Barry" <bceggers@castc om.com> wrote in message
                > >news:vdau10ddj 4cr8p9nf5s3i6uk sk0am0dtc9@4ax. com...[color=darkred]
                > >> Rather than try to post it all here, see if you can get this zip file
                > >>
                > >> http://home.comcast.net/~bceggers/do...nlockfiles.zip
                > >>
                > >> When you run the project, just enter the servername, click on "find
                > >> locked files", select a file from the list box and then click on
                > >> "unlock selected file" and that should do it for unlocking the file.
                > >>
                > >> Sorry about the choppy-ness of the code but i removed a lot of
                > >> debugging code. The tough part is where the CopyMemory is used to
                > >> grab selected information that is returned from some of the API calls
                > >> (we didn't need it all).
                > >>
                > >> If you have any questions, let me know and I'll see what I can do.
                > >>
                > >> Barry
                > >> bceggersATcomca stDOTnet
                > >>
                > >>
                > >> On Mon, 2 Feb 2004 08:17:43 -0500, "Atley" <atley_1@hotmai l.com>
                > >> wrote:
                > >>
                > >> >YES PLEASE....
                > >> >
                > >> >This problem has been a pain in our butts for over a week now...[/color][/color][/color]
                Please[color=blue][color=green][color=darkred]
                > >> >post..
                > >> >
                > >> >
                > >> >Atley
                > >> >
                > >> >
                > >> >
                > >> >"Barry" <bceggers@comca st.net> wrote in message
                > >> >news:pouo10h8k 27ggl8p4stu7cq4 uk4sfj80sj@4ax. com...
                > >> >> We have had success using the NetFileClose API. This has the effect
                > >> >> of unlocking the file. But it doesn't tell you if the MDB is in[/color][/color][/color]
                use.[color=blue][color=green][color=darkred]
                > >> >>
                > >> >> We have a time window and anybody on after that time window can be
                > >> >> disconnected from the MDB at any time.
                > >> >>
                > >> >> We have only run it when the mdb is on a server (w2000 but the docs
                > >> >> say it will work on an NT server) and the account running the
                > >> >> NetFileClose is an "operator" on the server.
                > >> >>
                > >> >> Notice that the API expects a Unicode string for the servername so[/color][/color][/color]
                the[color=blue][color=green][color=darkred]
                > >> >> normal call of (byval str as string) did not work for us.
                > >> >>
                > >> >> Public Declare Function NetFileClose lib "netapi32.d ll" _
                > >> >> (bvay lpstr as long, byval dword as long) as long
                > >> >>
                > >> >> We call it this way
                > >> >>
                > >> >> lngreturned = NetFileClose(St rPtr(filename), fileId)
                > >> >>
                > >> >> Now the fileid must be obtained from NetFileEenum API and that is[/color][/color][/color]
                not[color=blue][color=green][color=darkred]
                > >> >> for the faint of heart.
                > >> >>
                > >> >> Before I try to post some code ( I'll have to trim it some since we
                > >> >> have some misc debugging code in here)... Is this something that you
                > >> >> want to get into? I don't know of any other way to kick users out[/color][/color][/color]
                of[color=blue][color=green][color=darkred]
                > >> >> a file.
                > >> >>
                > >> >> In order to check on whether or not users are really using the MDB
                > >> >> file, I guess you would have to watch the file and check to see if[/color][/color][/color]
                it[color=blue][color=green][color=darkred]
                > >> >> was modified in the past X minutes (or set up a FileSystemWatch er
                > >> >> rahter than use the API calls) !!
                > >> >>
                > >> >>
                > >> >> On Fri, 30 Jan 2004 20:44:31 +0100, "Armin Zingler"
                > >> >> <az.nospam@free net.de> wrote:
                > >> >>
                > >> >> >"Atley" <atley_1@hotmai l.com> schrieb
                > >> >> >> I am trying to make sure that an MDB is not in use and then[/color][/color][/color]
                delete[color=blue][color=green][color=darkred]
                > >> >> >> it. If it is in use, I want to automatically disconnect all the
                > >> >> >> users and then delete the file.
                > >> >> >
                > >> >> >You can not disconnect the users. They have to close the file.
                > >> >>
                > >> >> bceggersATcomca stDOTnet
                > >> >
                > >>
                > >> bceggersATcomca stDOTnet[/color]
                > >[/color]
                >
                > bceggersATcomca stDOTnet[/color]


                Comment

                • Barry

                  #9
                  Re: Killing a MDB file

                  Hi, Atley,

                  Ok. working under the assumption that Domain Administrators are also
                  added to the Admin group on the server, the next thing is to put back
                  some of the debug code that I took out.

                  I'll try to get it back in this weekend and let you know when I have
                  the new zip file up for you to download.

                  It's probably one of the API calls that is failing and the debug code
                  (not being there...) isn't reporting it. Those failures are usually
                  due to permissions but that might not be the case here.

                  I'll be back to you soon.

                  Sorry for any delay.

                  Barry



                  On Tue, 3 Feb 2004 22:15:52 -0500, "Atley" <atley_1@hotmai l.com>
                  wrote:
                  [color=blue][color=green]
                  >> What is the OS of the server with the locked file?[/color]
                  >Windows 2000 Server
                  >[color=green]
                  >> Is the file in a public share?[/color]
                  >Yes
                  >[color=green]
                  >> What are the permissions for your account (admin,operator ,power user,
                  >> etc)?[/color]
                  >Domain Admin
                  >[color=green]
                  >> Do you have delete rights to that folder and file (when unlocked) ?[/color]
                  >Yes
                  >
                  >
                  >
                  >"Barry" <bceggers@castc om.com> wrote in message
                  >news:9pc020dql cq0vhl674c3af52 q5ed0fbbou@4ax. com...[color=green]
                  >> What is the OS of the server with the locked file?
                  >> Is the file in a public share?
                  >> What are the permissions for your account (admin,operator ,power user,
                  >> etc)?
                  >> Do you have delete rights to that folder and file (when unlocked) ?
                  >>
                  >> Barry
                  >>
                  >> On Tue, 3 Feb 2004 08:37:40 -0500, "Atley" <atley_1@hotmai l.com>
                  >> wrote:
                  >>[color=darkred]
                  >> >I tried the code, but even after unlocking the file I cannot delete it
                  >> >through explorer. Is there something else I have to do to make it so I[/color][/color]
                  >can[color=green][color=darkred]
                  >> >kill this MDB file?
                  >> >
                  >> >Atley
                  >> >
                  >> >
                  >> >
                  >> >"Barry" <bceggers@castc om.com> wrote in message
                  >> >news:vdau10ddj 4cr8p9nf5s3i6uk sk0am0dtc9@4ax. com...
                  >> >> Rather than try to post it all here, see if you can get this zip file
                  >> >>
                  >> >> http://home.comcast.net/~bceggers/do...nlockfiles.zip
                  >> >>
                  >> >> When you run the project, just enter the servername, click on "find
                  >> >> locked files", select a file from the list box and then click on
                  >> >> "unlock selected file" and that should do it for unlocking the file.
                  >> >>
                  >> >> Sorry about the choppy-ness of the code but i removed a lot of
                  >> >> debugging code. The tough part is where the CopyMemory is used to
                  >> >> grab selected information that is returned from some of the API calls
                  >> >> (we didn't need it all).
                  >> >>
                  >> >> If you have any questions, let me know and I'll see what I can do.
                  >> >>
                  >> >> Barry
                  >> >> bceggersATcomca stDOTnet
                  >> >>
                  >> >>
                  >> >> On Mon, 2 Feb 2004 08:17:43 -0500, "Atley" <atley_1@hotmai l.com>
                  >> >> wrote:
                  >> >>
                  >> >> >YES PLEASE....
                  >> >> >
                  >> >> >This problem has been a pain in our butts for over a week now...[/color][/color]
                  >Please[color=green][color=darkred]
                  >> >> >post..
                  >> >> >
                  >> >> >
                  >> >> >Atley
                  >> >> >
                  >> >> >
                  >> >> >
                  >> >> >"Barry" <bceggers@comca st.net> wrote in message
                  >> >> >news:pouo10h8k 27ggl8p4stu7cq4 uk4sfj80sj@4ax. com...
                  >> >> >> We have had success using the NetFileClose API. This has the effect
                  >> >> >> of unlocking the file. But it doesn't tell you if the MDB is in[/color][/color]
                  >use.[color=green][color=darkred]
                  >> >> >>
                  >> >> >> We have a time window and anybody on after that time window can be
                  >> >> >> disconnected from the MDB at any time.
                  >> >> >>
                  >> >> >> We have only run it when the mdb is on a server (w2000 but the docs
                  >> >> >> say it will work on an NT server) and the account running the
                  >> >> >> NetFileClose is an "operator" on the server.
                  >> >> >>
                  >> >> >> Notice that the API expects a Unicode string for the servername so[/color][/color]
                  >the[color=green][color=darkred]
                  >> >> >> normal call of (byval str as string) did not work for us.
                  >> >> >>
                  >> >> >> Public Declare Function NetFileClose lib "netapi32.d ll" _
                  >> >> >> (bvay lpstr as long, byval dword as long) as long
                  >> >> >>
                  >> >> >> We call it this way
                  >> >> >>
                  >> >> >> lngreturned = NetFileClose(St rPtr(filename), fileId)
                  >> >> >>
                  >> >> >> Now the fileid must be obtained from NetFileEenum API and that is[/color][/color]
                  >not[color=green][color=darkred]
                  >> >> >> for the faint of heart.
                  >> >> >>
                  >> >> >> Before I try to post some code ( I'll have to trim it some since we
                  >> >> >> have some misc debugging code in here)... Is this something that you
                  >> >> >> want to get into? I don't know of any other way to kick users out[/color][/color]
                  >of[color=green][color=darkred]
                  >> >> >> a file.
                  >> >> >>
                  >> >> >> In order to check on whether or not users are really using the MDB
                  >> >> >> file, I guess you would have to watch the file and check to see if[/color][/color]
                  >it[color=green][color=darkred]
                  >> >> >> was modified in the past X minutes (or set up a FileSystemWatch er
                  >> >> >> rahter than use the API calls) !!
                  >> >> >>
                  >> >> >>
                  >> >> >> On Fri, 30 Jan 2004 20:44:31 +0100, "Armin Zingler"
                  >> >> >> <az.nospam@free net.de> wrote:
                  >> >> >>
                  >> >> >> >"Atley" <atley_1@hotmai l.com> schrieb
                  >> >> >> >> I am trying to make sure that an MDB is not in use and then[/color][/color]
                  >delete[color=green][color=darkred]
                  >> >> >> >> it. If it is in use, I want to automatically disconnect all the
                  >> >> >> >> users and then delete the file.
                  >> >> >> >
                  >> >> >> >You can not disconnect the users. They have to close the file.
                  >> >> >>
                  >> >> >> bceggersATcomca stDOTnet
                  >> >> >
                  >> >>
                  >> >> bceggersATcomca stDOTnet
                  >> >[/color]
                  >>
                  >> bceggersATcomca stDOTnet[/color]
                  >[/color]

                  bceggersATcomca stDOTnet

                  Comment

                  • Barry

                    #10
                    Re: Killing a MDB file

                    BTW,

                    Did you convert the project to .NET or did you try it as vb6 ?

                    Barry

                    On Tue, 3 Feb 2004 22:15:52 -0500, "Atley" <atley_1@hotmai l.com>
                    wrote:
                    [color=blue][color=green]
                    >> What is the OS of the server with the locked file?[/color]
                    >Windows 2000 Server
                    >[color=green]
                    >> Is the file in a public share?[/color]
                    >Yes
                    >[color=green]
                    >> What are the permissions for your account (admin,operator ,power user,
                    >> etc)?[/color]
                    >Domain Admin
                    >[color=green]
                    >> Do you have delete rights to that folder and file (when unlocked) ?[/color]
                    >Yes
                    >
                    >
                    >
                    >"Barry" <bceggers@castc om.com> wrote in message
                    >news:9pc020dql cq0vhl674c3af52 q5ed0fbbou@4ax. com...[color=green]
                    >> What is the OS of the server with the locked file?
                    >> Is the file in a public share?
                    >> What are the permissions for your account (admin,operator ,power user,
                    >> etc)?
                    >> Do you have delete rights to that folder and file (when unlocked) ?
                    >>
                    >> Barry
                    >>
                    >> On Tue, 3 Feb 2004 08:37:40 -0500, "Atley" <atley_1@hotmai l.com>
                    >> wrote:
                    >>[color=darkred]
                    >> >I tried the code, but even after unlocking the file I cannot delete it
                    >> >through explorer. Is there something else I have to do to make it so I[/color][/color]
                    >can[color=green][color=darkred]
                    >> >kill this MDB file?
                    >> >
                    >> >Atley
                    >> >
                    >> >
                    >> >
                    >> >"Barry" <bceggers@castc om.com> wrote in message
                    >> >news:vdau10ddj 4cr8p9nf5s3i6uk sk0am0dtc9@4ax. com...
                    >> >> Rather than try to post it all here, see if you can get this zip file
                    >> >>
                    >> >> http://home.comcast.net/~bceggers/do...nlockfiles.zip
                    >> >>
                    >> >> When you run the project, just enter the servername, click on "find
                    >> >> locked files", select a file from the list box and then click on
                    >> >> "unlock selected file" and that should do it for unlocking the file.
                    >> >>
                    >> >> Sorry about the choppy-ness of the code but i removed a lot of
                    >> >> debugging code. The tough part is where the CopyMemory is used to
                    >> >> grab selected information that is returned from some of the API calls
                    >> >> (we didn't need it all).
                    >> >>
                    >> >> If you have any questions, let me know and I'll see what I can do.
                    >> >>
                    >> >> Barry
                    >> >> bceggersATcomca stDOTnet
                    >> >>
                    >> >>
                    >> >> On Mon, 2 Feb 2004 08:17:43 -0500, "Atley" <atley_1@hotmai l.com>
                    >> >> wrote:
                    >> >>
                    >> >> >YES PLEASE....
                    >> >> >
                    >> >> >This problem has been a pain in our butts for over a week now...[/color][/color]
                    >Please[color=green][color=darkred]
                    >> >> >post..
                    >> >> >
                    >> >> >
                    >> >> >Atley
                    >> >> >
                    >> >> >
                    >> >> >
                    >> >> >"Barry" <bceggers@comca st.net> wrote in message
                    >> >> >news:pouo10h8k 27ggl8p4stu7cq4 uk4sfj80sj@4ax. com...
                    >> >> >> We have had success using the NetFileClose API. This has the effect
                    >> >> >> of unlocking the file. But it doesn't tell you if the MDB is in[/color][/color]
                    >use.[color=green][color=darkred]
                    >> >> >>
                    >> >> >> We have a time window and anybody on after that time window can be
                    >> >> >> disconnected from the MDB at any time.
                    >> >> >>
                    >> >> >> We have only run it when the mdb is on a server (w2000 but the docs
                    >> >> >> say it will work on an NT server) and the account running the
                    >> >> >> NetFileClose is an "operator" on the server.
                    >> >> >>
                    >> >> >> Notice that the API expects a Unicode string for the servername so[/color][/color]
                    >the[color=green][color=darkred]
                    >> >> >> normal call of (byval str as string) did not work for us.
                    >> >> >>
                    >> >> >> Public Declare Function NetFileClose lib "netapi32.d ll" _
                    >> >> >> (bvay lpstr as long, byval dword as long) as long
                    >> >> >>
                    >> >> >> We call it this way
                    >> >> >>
                    >> >> >> lngreturned = NetFileClose(St rPtr(filename), fileId)
                    >> >> >>
                    >> >> >> Now the fileid must be obtained from NetFileEenum API and that is[/color][/color]
                    >not[color=green][color=darkred]
                    >> >> >> for the faint of heart.
                    >> >> >>
                    >> >> >> Before I try to post some code ( I'll have to trim it some since we
                    >> >> >> have some misc debugging code in here)... Is this something that you
                    >> >> >> want to get into? I don't know of any other way to kick users out[/color][/color]
                    >of[color=green][color=darkred]
                    >> >> >> a file.
                    >> >> >>
                    >> >> >> In order to check on whether or not users are really using the MDB
                    >> >> >> file, I guess you would have to watch the file and check to see if[/color][/color]
                    >it[color=green][color=darkred]
                    >> >> >> was modified in the past X minutes (or set up a FileSystemWatch er
                    >> >> >> rahter than use the API calls) !!
                    >> >> >>
                    >> >> >>
                    >> >> >> On Fri, 30 Jan 2004 20:44:31 +0100, "Armin Zingler"
                    >> >> >> <az.nospam@free net.de> wrote:
                    >> >> >>
                    >> >> >> >"Atley" <atley_1@hotmai l.com> schrieb
                    >> >> >> >> I am trying to make sure that an MDB is not in use and then[/color][/color]
                    >delete[color=green][color=darkred]
                    >> >> >> >> it. If it is in use, I want to automatically disconnect all the
                    >> >> >> >> users and then delete the file.
                    >> >> >> >
                    >> >> >> >You can not disconnect the users. They have to close the file.
                    >> >> >>
                    >> >> >> bceggersATcomca stDOTnet
                    >> >> >
                    >> >>
                    >> >> bceggersATcomca stDOTnet
                    >> >[/color]
                    >>
                    >> bceggersATcomca stDOTnet[/color]
                    >[/color]

                    bceggersATcomca stDOTnet

                    Comment

                    • Barry

                      #11
                      Re: Killing a MDB file

                      HI, Atley,

                      I added some code to the project to show messageboxes with error
                      numbers. There is also an .rtf file (CodeDescrripti on Numbers.rtf)
                      that will explain the error numbers.

                      And there is a version that will work in vb.net. Do NOT just use the
                      conversion wizard to go from vb6 to vb.net.

                      Here are the two new downloads -





                      Let me know what error numbers you are getting.

                      HTH,
                      Barry

                      On Sun, 08 Feb 2004 02:41:10 GMT, Barry <bceggers@castc om.com> wrote:
                      [color=blue]
                      >BTW,
                      >
                      >Did you convert the project to .NET or did you try it as vb6 ?
                      >
                      >Barry
                      >
                      >On Tue, 3 Feb 2004 22:15:52 -0500, "Atley" <atley_1@hotmai l.com>
                      >wrote:
                      >[color=green][color=darkred]
                      >>> What is the OS of the server with the locked file?[/color]
                      >>Windows 2000 Server
                      >>[color=darkred]
                      >>> Is the file in a public share?[/color]
                      >>Yes
                      >>[color=darkred]
                      >>> What are the permissions for your account (admin,operator ,power user,
                      >>> etc)?[/color]
                      >>Domain Admin
                      >>[color=darkred]
                      >>> Do you have delete rights to that folder and file (when unlocked) ?[/color]
                      >>Yes
                      >>
                      >>
                      >>
                      >>"Barry" <bceggers@castc om.com> wrote in message
                      >>news:9pc020dq lcq0vhl674c3af5 2q5ed0fbbou@4ax .com...[color=darkred]
                      >>> What is the OS of the server with the locked file?
                      >>> Is the file in a public share?
                      >>> What are the permissions for your account (admin,operator ,power user,
                      >>> etc)?
                      >>> Do you have delete rights to that folder and file (when unlocked) ?
                      >>>
                      >>> Barry
                      >>>
                      >>> On Tue, 3 Feb 2004 08:37:40 -0500, "Atley" <atley_1@hotmai l.com>
                      >>> wrote:
                      >>>
                      >>> >I tried the code, but even after unlocking the file I cannot delete it
                      >>> >through explorer. Is there something else I have to do to make it so I[/color]
                      >>can[color=darkred]
                      >>> >kill this MDB file?
                      >>> >
                      >>> >Atley
                      >>> >
                      >>> >
                      >>> >
                      >>> >"Barry" <bceggers@castc om.com> wrote in message
                      >>> >news:vdau10ddj 4cr8p9nf5s3i6uk sk0am0dtc9@4ax. com...
                      >>> >> Rather than try to post it all here, see if you can get this zip file
                      >>> >>
                      >>> >> http://home.comcast.net/~bceggers/do...nlockfiles.zip
                      >>> >>
                      >>> >> When you run the project, just enter the servername, click on "find
                      >>> >> locked files", select a file from the list box and then click on
                      >>> >> "unlock selected file" and that should do it for unlocking the file.
                      >>> >>
                      >>> >> Sorry about the choppy-ness of the code but i removed a lot of
                      >>> >> debugging code. The tough part is where the CopyMemory is used to
                      >>> >> grab selected information that is returned from some of the API calls
                      >>> >> (we didn't need it all).
                      >>> >>
                      >>> >> If you have any questions, let me know and I'll see what I can do.
                      >>> >>
                      >>> >> Barry
                      >>> >> bceggersATcomca stDOTnet
                      >>> >>
                      >>> >>
                      >>> >> On Mon, 2 Feb 2004 08:17:43 -0500, "Atley" <atley_1@hotmai l.com>
                      >>> >> wrote:
                      >>> >>
                      >>> >> >YES PLEASE....
                      >>> >> >
                      >>> >> >This problem has been a pain in our butts for over a week now...[/color]
                      >>Please[color=darkred]
                      >>> >> >post..
                      >>> >> >
                      >>> >> >
                      >>> >> >Atley
                      >>> >> >
                      >>> >> >
                      >>> >> >
                      >>> >> >"Barry" <bceggers@comca st.net> wrote in message
                      >>> >> >news:pouo10h8k 27ggl8p4stu7cq4 uk4sfj80sj@4ax. com...
                      >>> >> >> We have had success using the NetFileClose API. This has the effect
                      >>> >> >> of unlocking the file. But it doesn't tell you if the MDB is in[/color]
                      >>use.[color=darkred]
                      >>> >> >>
                      >>> >> >> We have a time window and anybody on after that time window can be
                      >>> >> >> disconnected from the MDB at any time.
                      >>> >> >>
                      >>> >> >> We have only run it when the mdb is on a server (w2000 but the docs
                      >>> >> >> say it will work on an NT server) and the account running the
                      >>> >> >> NetFileClose is an "operator" on the server.
                      >>> >> >>
                      >>> >> >> Notice that the API expects a Unicode string for the servername so[/color]
                      >>the[color=darkred]
                      >>> >> >> normal call of (byval str as string) did not work for us.
                      >>> >> >>
                      >>> >> >> Public Declare Function NetFileClose lib "netapi32.d ll" _
                      >>> >> >> (bvay lpstr as long, byval dword as long) as long
                      >>> >> >>
                      >>> >> >> We call it this way
                      >>> >> >>
                      >>> >> >> lngreturned = NetFileClose(St rPtr(filename), fileId)
                      >>> >> >>
                      >>> >> >> Now the fileid must be obtained from NetFileEenum API and that is[/color]
                      >>not[color=darkred]
                      >>> >> >> for the faint of heart.
                      >>> >> >>
                      >>> >> >> Before I try to post some code ( I'll have to trim it some since we
                      >>> >> >> have some misc debugging code in here)... Is this something that you
                      >>> >> >> want to get into? I don't know of any other way to kick users out[/color]
                      >>of[color=darkred]
                      >>> >> >> a file.
                      >>> >> >>
                      >>> >> >> In order to check on whether or not users are really using the MDB
                      >>> >> >> file, I guess you would have to watch the file and check to see if[/color]
                      >>it[color=darkred]
                      >>> >> >> was modified in the past X minutes (or set up a FileSystemWatch er
                      >>> >> >> rahter than use the API calls) !!
                      >>> >> >>
                      >>> >> >>
                      >>> >> >> On Fri, 30 Jan 2004 20:44:31 +0100, "Armin Zingler"
                      >>> >> >> <az.nospam@free net.de> wrote:
                      >>> >> >>
                      >>> >> >> >"Atley" <atley_1@hotmai l.com> schrieb
                      >>> >> >> >> I am trying to make sure that an MDB is not in use and then[/color]
                      >>delete[color=darkred]
                      >>> >> >> >> it. If it is in use, I want to automatically disconnect all the
                      >>> >> >> >> users and then delete the file.
                      >>> >> >> >
                      >>> >> >> >You can not disconnect the users. They have to close the file.
                      >>> >> >>
                      >>> >> >> bceggersATcomca stDOTnet
                      >>> >> >
                      >>> >>
                      >>> >> bceggersATcomca stDOTnet
                      >>> >
                      >>>
                      >>> bceggersATcomca stDOTnet[/color]
                      >>[/color]
                      >
                      >bceggersATcomc astDOTnet[/color]

                      bceggersATcomca stDOTnet

                      Comment

                      Working...