Hi,
here is my code:
Process proc = new Process();
proc.StartInfo.UseShellExecute = true;
proc.StartInfo.FileName = @"C:\robocopy.exe";
String temp = (fi.FullName).ToString();
temp = temp.Replace("\\" + fi.Name,"");
proc.StartInfo.Arguments = temp + " " + target.ToString() + " " + fi.Name;
proc.Start();
Everything works well WITH showing every copy process in shell/cmd window. If I set the proc.StartInfo.UseShellExecute = false; or
proc.StartInfo.CreateNoWindow = true; or both the files are copied, although don't know if all (hundreds of GBs) but I got warning/errors pop ups:
application failed to initialize ...
My try was to change the registry key Windows, from HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems\system32\csrss.exe, value to %SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,20480,768 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ProfileControl=Off MaxRequestThreads=16
(see: http://aceshardware.freeforums.org/i-think-i-ve-uncovered-a-major-issue-in-windows-t458.html)
but I still got it.
If somebody has an idea i will apreciate it.
Regards,
Adrian
Loading

naura paxRank #2,843 · 502 reputationPosted Nov 26, 2009, 10:20 PM EST
Adrian Albu11 reputationPosted Nov 26, 2009, 10:29 PM EST
fi is a FileInfo and the aruments to run the robocopy translate into something like:
proc.StartInfo.Arguments = @"e:\Data\customerx e:\targetfolder filename2becopied"
10x for interest
naura paxRank #2,843 · 502 reputationPosted Nov 26, 2009, 10:41 PM EST
Adrian Albu11 reputationPosted Nov 26, 2009, 10:51 PM EST
temp = temp.Replace("\\" + fi.Name,"");
proc.StartInfo.Arguments = temp + " " + target.ToString() + " " + fi.Name;
First line is used to take the path to file, from full path takea away the file name ,
so from something like: fi.FullName @"e:\Data\9812\BEST\060207.S00021759.BMOB.6-1-142-19594.TIF" string
takes fi.Name "060207.S00021759.BMOB.6-1-142-19594.TIF" string
so temp will be: temp @"e:\Data\9812\BEST" string
in 3rd line I set the arguments needed for robocopy to copy from folder source to target for that file
proc.StartInfo.Arguments @"e:\Data\9812\BEST e:\invoicesBE\9812\BEST 060207.S00021759.BMOB.6-1-142-19594.TIF" string
naura paxRank #2,843 · 502 reputationPosted Nov 26, 2009, 11:29 PM EST
Adrian Albu11 reputationPosted Nov 26, 2009, 11:42 PM EST
actually if all code is run with proc.StartInfo.UseShellExecute = true; than works like charmed
but if I set proc.StartInfo.UseShellExecute = false; or with proc.StartInfo.CreateNoWindow = true; than I see nothing, no windows for copy processes but I got pop ups with that error: application failed to initialize,
what I could find until now is that windows has a limit of how many files to be copied at once or something but really I do not think this is it since if I let the command shell windows to be opened everything works well.
I do not want to open the windows because it takes form execution time, also are so many and so fast they open-close that I cannot have focus on other application :)
Adrian Albu11 reputationPosted Nov 27, 2009, 1:40 AM EST
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
Thnaks youfor effort anyway :)