Process.Start throws Access Denied Win32Exception

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?ams=?=

    Process.Start throws Access Denied Win32Exception

    I am using System.Diagnost ics.Process class to open a word document by call
    ing Process.Start(" test.doc"). I am using C# as programming language. On some
    of the computers on running this code i get "Access is Denied"
    Win32Exception. What do i do to not generate this exception ?

    Any help highly appreciated,

    Thanks,

    Jay
  • Lau Lei Cheong

    #2
    Re: Process.Start throws Access Denied Win32Exception

    Either the user do not have right to access the "test.doc", or does not have
    right to start MSWord or whatever assigned to open the "test.doc" (like
    WordPad).

    Go check whether they can open the file directly first.

    "jk" <jk@discussions .microsoft.com¼ ¶¼g©ó¶l¥ó·s»D:1 CFBA243-1841-4182-9362-7A4A00747EDB@mi crosoft.com...
    >I am using System.Diagnost ics.Process class to open a word document by call
    ing Process.Start(" test.doc"). I am using C# as programming language. On
    some
    of the computers on running this code i get "Access is Denied"
    Win32Exception. What do i do to not generate this exception ?
    >
    Any help highly appreciated,
    >
    Thanks,
    >
    Jay

    Comment

    • =?Utf-8?B?ams=?=

      #3
      Re: Process.Start throws Access Denied Win32Exception

      Thanks Lau,
      That is the first thing i did was to check the permissions and
      really the permissions are the same, and to confirm the problem
      was not related to permissions, I even logged in as a Administrator
      and ran the application.

      Basically, I am trying to export data to word document, for which i am
      taking the following steps.

      I have a richtextbox which shows data to user, as and when the user
      is happy with the data, he clicks export, so a save as file dialog pops
      up and user can give a name to the file and store it where he wants.
      Now after he clicks save, and the control returns to our program,
      i fire the Process.Start(" filename") which the user had assigned.
      Now i dont get why this works on 5 / 6 machines and fails only on the
      one laptop ! i have checked permisions of each and every folder possible.

      Hope this explains my problem, and if possible u might have an idea to solve
      it
      Thanks,
      Jay

      "Lau Lei Cheong" wrote:
      Either the user do not have right to access the "test.doc", or does not have
      right to start MSWord or whatever assigned to open the "test.doc" (like
      WordPad).
      >
      Go check whether they can open the file directly first.
      >
      "jk" <jk@discussions .microsoft.com ¼Â¶Â¼g©ó¶lÂ¥ ó·s»D:1CFBA2 43-1841-4182-9362-7A4A00747EDB@mi crosoft.com...
      I am using System.Diagnost ics.Process class to open a word document by call
      ing Process.Start(" test.doc"). I am using C# as programming language. On
      some
      of the computers on running this code i get "Access is Denied"
      Win32Exception. What do i do to not generate this exception ?

      Any help highly appreciated,

      Thanks,

      Jay
      >
      >
      >

      Comment

      • Lau Lei Cheong

        #4
        Re: Process.Start throws Access Denied Win32Exception

        Could it be because the file is not completely saved when you run
        Process.Start() ?

        See if it helps to run a loop on File.Open() on the path until it returns a
        handle, close the FileStream and use Process.Start() to open it.

        Or it'd be neater if just Thread.Sleep() for 2 seconds in between...

        "jk" <jk@discussions .microsoft.com¼ ¶¼g©ó¶l¥ó·s»D:2 B2090FF-43F3-4574-AD9F-AB8D94885E3B@mi crosoft.com...
        Thanks Lau,
        That is the first thing i did was to check the permissions and
        really the permissions are the same, and to confirm the problem
        was not related to permissions, I even logged in as a Administrator
        and ran the application.
        >
        Basically, I am trying to export data to word document, for which i am
        taking the following steps.
        >
        I have a richtextbox which shows data to user, as and when the user
        is happy with the data, he clicks export, so a save as file dialog pops
        up and user can give a name to the file and store it where he wants.
        Now after he clicks save, and the control returns to our program,
        i fire the Process.Start(" filename") which the user had assigned.
        Now i dont get why this works on 5 / 6 machines and fails only on the
        one laptop ! i have checked permisions of each and every folder possible.
        >
        Hope this explains my problem, and if possible u might have an idea to
        solve
        it
        Thanks,
        Jay
        >
        "Lau Lei Cheong" wrote:
        >
        >Either the user do not have right to access the "test.doc", or does not
        >have
        >right to start MSWord or whatever assigned to open the "test.doc" (like
        >WordPad).
        >>
        >Go check whether they can open the file directly first.
        >>
        >"jk" <jk@discussions .microsoft.com? ??gcˆu?l¢Dˆu¡Ps ?D:1CFBA243-1841-4182-9362-7A4A00747EDB@mi crosoft.com...
        >>
        >I am using System.Diagnost ics.Process class to open a word document by
        >call
        ing Process.Start(" test.doc"). I am using C# as programming language.
        On
        some
        of the computers on running this code i get "Access is Denied"
        Win32Exception. What do i do to not generate this exception ?
        >
        Any help highly appreciated,
        >
        Thanks,
        >
        Jay
        >>
        >>
        >>

        Comment

        • VJ

          #5
          Re: Process.Start throws Access Denied Win32Exception

          Try using reflection to open word objects or any Microsoft office
          application. Eliminates all these process / file lock issues ( will not
          security issues )



          The link can get you started.. If you have furthers question on this method
          please ask!

          VJ

          "Lau Lei Cheong" <leu_lc@yehoo.c om.hkwrote in message
          news:%235RYTxuZ HHA.1388@TK2MSF TNGP05.phx.gbl. ..
          Could it be because the file is not completely saved when you run
          Process.Start() ?
          >
          See if it helps to run a loop on File.Open() on the path until it returns
          a handle, close the FileStream and use Process.Start() to open it.
          >
          Or it'd be neater if just Thread.Sleep() for 2 seconds in between...
          >
          "jk" <jk@discussions .microsoft.com>
          ¼¶¼g©ó¶l¥ó·s»D: 2B2090FF-43F3-4574-AD9F-AB8D94885E3B@mi crosoft.com...
          >Thanks Lau,
          >That is the first thing i did was to check the permissions and
          >really the permissions are the same, and to confirm the problem
          >was not related to permissions, I even logged in as a Administrator
          >and ran the application.
          >>
          >Basically, I am trying to export data to word document, for which i am
          >taking the following steps.
          >>
          >I have a richtextbox which shows data to user, as and when the user
          >is happy with the data, he clicks export, so a save as file dialog pops
          >up and user can give a name to the file and store it where he wants.
          >Now after he clicks save, and the control returns to our program,
          >i fire the Process.Start(" filename") which the user had assigned.
          >Now i dont get why this works on 5 / 6 machines and fails only on the
          >one laptop ! i have checked permisions of each and every folder possible.
          >>
          >Hope this explains my problem, and if possible u might have an idea to
          >solve
          >it
          >Thanks,
          >Jay
          >>
          >"Lau Lei Cheong" wrote:
          >>
          >>Either the user do not have right to access the "test.doc", or does not
          >>have
          >>right to start MSWord or whatever assigned to open the "test.doc" (like
          >>WordPad).
          >>>
          >>Go check whether they can open the file directly first.
          >>>
          >>"jk" <jk@discussions .microsoft.com>
          >>???gc^u?l¢D^u ¡Ps?D:1CFBA243-1841-4182-9362-7A4A00747EDB@mi crosoft.com...
          >>I am using System.Diagnost ics.Process class to open a word document by
          >>call
          >ing Process.Start(" test.doc"). I am using C# as programming language.
          >On
          >some
          >of the computers on running this code i get "Access is Denied"
          >Win32Exception . What do i do to not generate this exception ?
          >>
          >Any help highly appreciated,
          >>
          >Thanks,
          >>
          >Jay
          >>>
          >>>
          >>>
          >
          >

          Comment

          • =?Utf-8?B?ams=?=

            #6
            Re: Process.Start throws Access Denied Win32Exception

            Thanks for your reply Lau and VJ,

            Reflection i think would be too heavy duty to just open a
            word file, but may be give it a go and see.

            Still have not found a solution for this problem,
            but will post it whenever i have any.

            Let me know if u guys have any other ideas on the same,

            thanks

            jay

            "VJ" wrote:
            Try using reflection to open word objects or any Microsoft office
            application. Eliminates all these process / file lock issues ( will not
            security issues )
            >

            >
            The link can get you started.. If you have furthers question on this method
            please ask!
            >
            VJ
            >
            "Lau Lei Cheong" <leu_lc@yehoo.c om.hkwrote in message
            news:%235RYTxuZ HHA.1388@TK2MSF TNGP05.phx.gbl. ..
            Could it be because the file is not completely saved when you run
            Process.Start() ?

            See if it helps to run a loop on File.Open() on the path until it returns
            a handle, close the FileStream and use Process.Start() to open it.

            Or it'd be neater if just Thread.Sleep() for 2 seconds in between...

            "jk" <jk@discussions .microsoft.com>
            ¼¶¼g©ó¶l ¥Ã³Â·s»D:2B209 0FF-43F3-4574-AD9F-AB8D94885E3B@mi crosoft.com...
            Thanks Lau,
            That is the first thing i did was to check the permissions and
            really the permissions are the same, and to confirm the problem
            was not related to permissions, I even logged in as a Administrator
            and ran the application.
            >
            Basically, I am trying to export data to word document, for which i am
            taking the following steps.
            >
            I have a richtextbox which shows data to user, as and when the user
            is happy with the data, he clicks export, so a save as file dialog pops
            up and user can give a name to the file and store it where he wants.
            Now after he clicks save, and the control returns to our program,
            i fire the Process.Start(" filename") which the user had assigned.
            Now i dont get why this works on 5 / 6 machines and fails only on the
            one laptop ! i have checked permisions of each and every folder possible.
            >
            Hope this explains my problem, and if possible u might have an idea to
            solve
            it
            Thanks,
            Jay
            >
            "Lau Lei Cheong" wrote:
            >
            >Either the user do not have right to access the "test.doc", or does not
            >have
            >right to start MSWord or whatever assigned to open the "test.doc" (like
            >WordPad).
            >>
            >Go check whether they can open the file directly first.
            >>
            >"jk" <jk@discussions .microsoft.com>
            >???gc^u?l¢D^u ¡Ps?D:1CFBA243-1841-4182-9362-7A4A00747EDB@mi crosoft.com...
            >I am using System.Diagnost ics.Process class to open a word document by
            >call
            ing Process.Start(" test.doc"). I am using C# as programming language.
            On
            some
            of the computers on running this code i get "Access is Denied"
            Win32Exception. What do i do to not generate this exception ?
            >
            Any help highly appreciated,
            >
            Thanks,
            >
            Jay
            >>
            >>
            >>
            >
            >
            >

            Comment

            • =?Utf-8?B?ams=?=

              #7
              Re: Process.Start throws Access Denied Win32Exception


              Hi,
              I think i have much better explanation of the same problem in this post:
              Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


              Thanks,

              Jay
              "jk" wrote:
              Thanks for your reply Lau and VJ,
              >
              Reflection i think would be too heavy duty to just open a
              word file, but may be give it a go and see.
              >
              Still have not found a solution for this problem,
              but will post it whenever i have any.
              >
              Let me know if u guys have any other ideas on the same,
              >
              thanks
              >
              jay
              >
              "VJ" wrote:
              >
              Try using reflection to open word objects or any Microsoft office
              application. Eliminates all these process / file lock issues ( will not
              security issues )



              The link can get you started.. If you have furthers question on this method
              please ask!

              VJ

              "Lau Lei Cheong" <leu_lc@yehoo.c om.hkwrote in message
              news:%235RYTxuZ HHA.1388@TK2MSF TNGP05.phx.gbl. ..
              Could it be because the file is not completely saved when you run
              Process.Start() ?
              >
              See if it helps to run a loop on File.Open() on the path until it returns
              a handle, close the FileStream and use Process.Start() to open it.
              >
              Or it'd be neater if just Thread.Sleep() for 2 seconds in between...
              >
              "jk" <jk@discussions .microsoft.com>
              ¼¶¼g©ó¶l ¥Ã³Â·s»D:2B209 0FF-43F3-4574-AD9F-AB8D94885E3B@mi crosoft.com...
              >Thanks Lau,
              >That is the first thing i did was to check the permissions and
              >really the permissions are the same, and to confirm the problem
              >was not related to permissions, I even logged in as a Administrator
              >and ran the application.
              >>
              >Basically, I am trying to export data to word document, for which i am
              >taking the following steps.
              >>
              >I have a richtextbox which shows data to user, as and when the user
              >is happy with the data, he clicks export, so a save as file dialog pops
              >up and user can give a name to the file and store it where he wants.
              >Now after he clicks save, and the control returns to our program,
              >i fire the Process.Start(" filename") which the user had assigned.
              >Now i dont get why this works on 5 / 6 machines and fails only on the
              >one laptop ! i have checked permisions of each and every folder possible.
              >>
              >Hope this explains my problem, and if possible u might have an idea to
              >solve
              >it
              >Thanks,
              >Jay
              >>
              >"Lau Lei Cheong" wrote:
              >>
              >>Either the user do not have right to access the "test.doc", or does not
              >>have
              >>right to start MSWord or whatever assigned to open the "test.doc" (like
              >>WordPad).
              >>>
              >>Go check whether they can open the file directly first.
              >>>
              >>"jk" <jk@discussions .microsoft.com>
              >>???gc^u?l¢D^ u¡Ps?D:1CFBA24 3-1841-4182-9362-7A4A00747EDB@mi crosoft.com...
              >>I am using System.Diagnost ics.Process class to open a word document by
              >>call
              >ing Process.Start(" test.doc"). I am using C# as programming language.
              >On
              >some
              >of the computers on running this code i get "Access is Denied"
              >Win32Exception . What do i do to not generate this exception ?
              >>
              >Any help highly appreciated,
              >>
              >Thanks,
              >>
              >Jay
              >>>
              >>>
              >>>
              >
              >

              Comment

              • Lau Lei Cheong

                #8
                Re: Process.Start throws Access Denied Win32Exception

                Strange... it yet looks like a permission problem.(ACL while file copy
                follows its parent.)

                Would you mind to run "cacls test.doc" on the "Program Files" folder and
                paste the output here?

                Feel free to mask out the account names, but just let us know which one is
                the account your application is running on.

                "jk" <jk@discussions .microsoft.com¼ ¶¼g©ó¶l¥ó·s»D:B ACFFA4C-BA85-497F-8DCB-FBCB0C83A1A5@mi crosoft.com...
                >
                Hi,
                I think i have much better explanation of the same problem in this post:
                Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

                >
                Thanks,
                >
                Jay
                "jk" wrote:
                >
                >Thanks for your reply Lau and VJ,
                >>
                >Reflection i think would be too heavy duty to just open a
                >word file, but may be give it a go and see.
                >>
                >Still have not found a solution for this problem,
                >but will post it whenever i have any.
                >>
                >Let me know if u guys have any other ideas on the same,
                >>
                >thanks
                >>
                >jay
                >>
                >"VJ" wrote:
                >>
                Try using reflection to open word objects or any Microsoft office
                application. Eliminates all these process / file lock issues ( will not
                security issues )
                >

                >
                The link can get you started.. If you have furthers question on this
                method
                please ask!
                >
                VJ
                >
                "Lau Lei Cheong" <leu_lc@yehoo.c om.hkwrote in message
                news:%235RYTxuZ HHA.1388@TK2MSF TNGP05.phx.gbl. ..
                Could it be because the file is not completely saved when you run
                Process.Start() ?
                >
                See if it helps to run a loop on File.Open() on the path until it
                returns
                a handle, close the FileStream and use Process.Start() to open it.
                >
                Or it'd be neater if just Thread.Sleep() for 2 seconds in between...
                >
                "jk" <jk@discussions .microsoft.com>
                ???gcˆu?l¢Dˆu¡P s?D:2B2090FF-43F3-4574-AD9F-AB8D94885E3B@mi crosoft.com...
                >
                >Thanks Lau,
                >That is the first thing i did was to check the permissions and
                >really the permissions are the same, and to confirm the problem
                >was not related to permissions, I even logged in as a Administrator
                >and ran the application.
                >>
                >Basically, I am trying to export data to word document, for which i
                >am
                >taking the following steps.
                >>
                >I have a richtextbox which shows data to user, as and when the user
                >is happy with the data, he clicks export, so a save as file dialog
                >pops
                >up and user can give a name to the file and store it where he wants.
                >Now after he clicks save, and the control returns to our program,
                >i fire the Process.Start(" filename") which the user had assigned.
                >Now i dont get why this works on 5 / 6 machines and fails only on
                >the
                >one laptop ! i have checked permisions of each and every folder
                >possible.
                >>
                >Hope this explains my problem, and if possible u might have an idea
                >to
                >solve
                >it
                >Thanks,
                >Jay
                >>
                >"Lau Lei Cheong" wrote:
                >>
                >>Either the user do not have right to access the "test.doc", or does
                >>not
                >>have
                >>right to start MSWord or whatever assigned to open the "test.doc"
                >>(like
                >>WordPad).
                >>>
                >>Go check whether they can open the file directly first.
                >>>
                >>"jk" <jk@discussions .microsoft.com>
                >>???gc^u?l¢FD^ u!Ps?D:1CFBA243-1841-4182-9362-7A4A00747EDB@mi crosoft.com...
                >>I am using System.Diagnost ics.Process class to open a word
                >>document by
                >>call
                >ing Process.Start(" test.doc"). I am using C# as programming
                >language.
                >On
                >some
                >of the computers on running this code i get "Access is Denied"
                >Win32Exception . What do i do to not generate this exception ?
                >>
                >Any help highly appreciated,
                >>
                >Thanks,
                >>
                >Jay
                >>>
                >>>
                >>>
                >
                >
                >
                >
                >

                Comment

                Working...