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
Adrian AlbuPosted Nov 27, 2009, 6:40 AM
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
Thnaks youfor effort anyway :)
Adrian AlbuPosted Nov 27, 2009, 4:42 AM
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 :)
naura paxPosted Nov 27, 2009, 4:29 AM
Adrian AlbuPosted Nov 27, 2009, 3:51 AM
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 paxPosted Nov 27, 2009, 3:41 AM
Adrian AlbuPosted Nov 27, 2009, 3:29 AM
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 paxPosted Nov 27, 2009, 3:20 AM