0

i'm starting a child application from my main process with the following code:

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = DestinationNameEXE;
startInfo.WorkingDirectory = Toolbox.AssemblyDirectory;
startInfo.UseShellExecute = true;
startInfo.Arguments =
binParameter + @" """ + _BINPath + @" """
+ tmpParameter + @" """ + binFolder_ForExtration + @" """;
Process.Start(startInfo);

before i do this i check if the process has write rights in the binFolder_ForExtration and _BInPath with following code (source) and a simple write file check:

try
{
    using (File.Create(tmpfile)) { }
    File.Delete(tmpfile);
    createFilesAllow = true;
}
catch
{
    createFilesAllow = false;    
}

in the main process i can write & create files. also the function HasWritePermissionOnDir returns true. in the new process i'm doing the same test, but in this case i got from HasWritePermissionOnDir true, but if i try to create a file, i got an exception. the new process has the rights to change existing files.

how can this be? what i'm doing wrong? how can the new process have less rights then the first process? i don't change the user context.

i' have also tested to start the process with ProcessAsUser.Launch (source) but without any change. the new process dond't have the right to create new files in the given folder.

if i start the process with elevated rights:

startInfo.Verb = "runas";

everything works finde. the new process can write, create and change files in the given folder.

thx for any help

Update:

  • i'm testing on a windows 7 x86
  • the main process is compiled with target x86 and .Net 4.5. its a dll called from a vb6 application
  • the user i'm testing with has admin rights (but it's not the user administrator). the main process is started with normal rights settings (not elevated rights)
  • the new process is compiled with target any CPU and .Net 4.5.
  • since i require access to Process.GetProcesses in the new process it should be compiled as any CPU to be used on x86 and x64 systems (as far as i know)
  • currently all folder tests and occured errors happend in the folder *c:\Program Files (x86)\appname\BIN*. in the code i'm using full path and test the correctness of the path with direcotry.exist() bevore any execution.
Community
  • 1
  • 1
Roland
  • 113
  • 2
  • 11
  • This requires wild guessing as long as you don't properly document the specific directories. The bitness of the process matters, affects the file system redirector. Not using full path names (i.e. "foo.bar" instead of "c:\dir\foo.bar") is a standard failure mode. – Hans Passant Apr 23 '14 at 17:16
  • You should be able to specify credentials when starting a new process, so you can define which rights to use. – Allan S. Hansen Apr 24 '14 at 05:55

0 Answers0