Why do I get a different result if I run a command from the CLI and the same command from a Winform application?

Sylvebarbe78 0 Reputation points
2023-03-23T15:05:00.6866667+00:00

Hello,

Sorry for my poor English...

not same result !?

I encounter a very curious problem. Indeed, I wrote a small program that launches a CLI command from a Winform application and I retrieve the result asynchronously using the ProcessStartInfo() and Process() duo and I read the result as I go. data feedback via a While loop and StreamReader.

Everything works fine except that I encounter something inexplicable. When I launch for example the following statement from the command interpreter as an administrator (displays the junction points contained in a directory and its subdirectories), the latter returns me a different result from the one obtained from the Winform application with the same instructions (also run as Administrator) !!!?

CLI command executed:

dir c:\windows /AL /S

Result obtained from the command interpreter:

Répertoire de c:\windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\Windows\INetCache
01/10/2022 23:26 <JUNCTION> Content.IE5 [C:\WINDOWS\ServiceProfiles\NetworkService\AppData\Local\Microsoft\Windows\INetCache\IE]
0 fichier(s) 0 octets
Répertoire de c:\windows\System32\config\systemprofile\AppData\Local\Microsoft\Windows\INetCache
28/09/2022 16:11 <JUNCTION> Content.IE5 [C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\Windows\INetCache\IE]
0 fichier(s) 0 octets

Result obtained from the Winform application:

Répertoire de c:\windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\Windows\INetCache
01/10/2022 23:26 <JUNCTION> Content.IE5 [C:\WINDOWS\ServiceProfiles\NetworkService\AppData\Local\Microsoft\Windows\INetCache\IE]
0 fichier(s) 0 octets

Does anyone have an explanation for me to solve this mystery?

Best regards

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,884 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,829 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sylvebarbe78 0 Reputation points
    2023-03-25T14:20:08.3233333+00:00

    @ David Lowndes, Viorel

    Hello !

    I unchecked the Prefer 32 bit option as you told me and it works. The junction point appears ! :-)

    If I understand correctly, as I am developing on a 64-bit system, when I want to develop an application that is compatible at best with the 2 systems (32 and 64) it is better for greater compatibility to uncheck this option?

    A big thank you to you !

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.