using process call .vbs to copy file.....
-
Hi, I am using Process to run a .vbs script to copy a folder and the files in the folder from one server to another server. The code is as below : Process myProcess = new Process(); myProcess.StartInfo.FileName = string.Concat(dirRoot.FullName, "\\myscript.vbs"); myProcess.StartInfo.Arguments = string.Concat("arg1, arg2, arg3, arg4, arg5"); myProcess.StartInfo.CreateNoWindow = true; myProcess.Start(); The arg2 and arg3 are source system login, the arg4 and arg5 are the login for destination system login. The .vbs file uses Script.FileSystemObject and wscript.Network to do the folder creation and copy file. Here is part of code: 'Open File System Object Set oFSO = CreateObject("Scripting.FileSystemObject") 'Open Network System Object Set oNSO = CreateObject("wscript.Network") .... oNSO.MapNetworkDrive "I:", "\\web1\c$", false, sSourceLogin, sSourcePassword oNSO.MapNetworkDrive "J:", "\\web2\d$", false, sDestLogin, sDestPassword ... wscript.echo sSourceFolder1 & " --> " & sDestinationFolder1 oFSO.CreateFolder sDestinationFolder1 oFSO.CopyFolder sSourceFolder1, sDestinationFolder1 ... When I run the project on my local machine, it works ok. it means, the files are copied from my local machine to a testing server. But the problem came out when I run the project on real server, nothing is done. No error is reported and no file is copied. I did config the IIS on the source server to enable execute permission to be script and executables for the folder containing the .vbs script file. Does anybody have similiar experience? Any help would be very appreciated! Thanks,
-
Hi, I am using Process to run a .vbs script to copy a folder and the files in the folder from one server to another server. The code is as below : Process myProcess = new Process(); myProcess.StartInfo.FileName = string.Concat(dirRoot.FullName, "\\myscript.vbs"); myProcess.StartInfo.Arguments = string.Concat("arg1, arg2, arg3, arg4, arg5"); myProcess.StartInfo.CreateNoWindow = true; myProcess.Start(); The arg2 and arg3 are source system login, the arg4 and arg5 are the login for destination system login. The .vbs file uses Script.FileSystemObject and wscript.Network to do the folder creation and copy file. Here is part of code: 'Open File System Object Set oFSO = CreateObject("Scripting.FileSystemObject") 'Open Network System Object Set oNSO = CreateObject("wscript.Network") .... oNSO.MapNetworkDrive "I:", "\\web1\c$", false, sSourceLogin, sSourcePassword oNSO.MapNetworkDrive "J:", "\\web2\d$", false, sDestLogin, sDestPassword ... wscript.echo sSourceFolder1 & " --> " & sDestinationFolder1 oFSO.CreateFolder sDestinationFolder1 oFSO.CopyFolder sSourceFolder1, sDestinationFolder1 ... When I run the project on my local machine, it works ok. it means, the files are copied from my local machine to a testing server. But the problem came out when I run the project on real server, nothing is done. No error is reported and no file is copied. I did config the IIS on the source server to enable execute permission to be script and executables for the folder containing the .vbs script file. Does anybody have similiar experience? Any help would be very appreciated! Thanks,
I would ensure the following calls create COM objects successfully. Set oFSO = CreateObject("Scripting.FileSystemObject") Set oNSO = CreateObject("wscript.Network") I will also check on \\web1\c$ \\web2\d$ access from the production server using the same security context that runs the .vbs script
-
I would ensure the following calls create COM objects successfully. Set oFSO = CreateObject("Scripting.FileSystemObject") Set oNSO = CreateObject("wscript.Network") I will also check on \\web1\c$ \\web2\d$ access from the production server using the same security context that runs the .vbs script
I have read some article about "To spawn a process that runs under the context of the impersonated user, you cannot use the System.Diagnostics.Process.Start method" at http://support.microsoft.com/kb/889251. Since I use both Windows Authentication and impersonate=true, I guess that's why the process couldn't start at all. But the solution posted at the above link only apply to asp.net 1.0 and 1.1. I am using asp.net 2.0 .... So I am still struggling to try to find a solution for the problem.... Do you have any ideas? Thank you in advance!