Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. using process call .vbs to copy file.....

using process call .vbs to copy file.....

Scheduled Pinned Locked Moved ASP.NET
helpsysadmincsharpwindows-admintesting
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vicky457
    wrote on last edited by
    #1

    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 1 Reply Last reply
    0
    • V vicky457

      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 Offline
      I Offline
      indianet
      wrote on last edited by
      #2

      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

      V 1 Reply Last reply
      0
      • I indianet

        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

        V Offline
        V Offline
        vicky457
        wrote on last edited by
        #3

        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!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups