none
vbscript to start program from share on remote computer fails

    Question

  • All the computers are in the ActiveDirectory 2003 Domain and I use a domain admin account which belongs to the Administrators group of the remote computer

    I found the following script, which works IF the file is on the harddisk of the remote computer (in this example on the root of the C disk):

    sCommandline ="c:\WindowsXP-KB942288-v3-x86.exe  /quiet /norestart"

    CreateProcess sComputer, sCommandline, "C:\" works.

    BUT

    if sCommandline = "\\Server0\Share0\app.exe"  thus a share, I always get access denied (error 2).

    Function CreateProcess( sComputer, sCommandline, sFolder )
        On Error Resume Next
        Set proc = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & sComputer & "\root\cimv2:Win32_Process")
        If Err.Number <> 0 Then
     WScript.Echo sComputer & "Createprocess ERROR:" & Err.Description
            Exit Function
        End If
     wscript.echo scommandline + "/**/" + sfolder
     ' oorspronkelijk   iRet = proc.Create(sCommandline, sFolder, null, iPID)

        iRet = proc.Create(sCommandline, null, null, iPID)
        If iRet <> 0 Then
            Select Case iRet
                Case 2 msg = "Access denied"
                Case 3 msg = "Insufficient privilege"
                Case 8 msg = "Unknown failure"
                Case 9 msg = "Path not found"
                Case 21 msg = "Invalid parameter"
                Case Else msg = "Unexpected return vlue"
            End Select
            WScript.Echo "CreateProcess:" & msg
        End If
       
    End Function

    Is there a solution available?

    Thanks.

    Wednesday, March 14, 2012 2:16 PM

Answers

  • Hi,

    You are attempting to connect remotely to a network resource from WMI using DCOM impersonation. This is tricky to get working properly.

    My usual solutions are to either: 1) copy the executable to the remote computer first, or 2) use the task scheduler to run the program.

    Bill

    Wednesday, March 14, 2012 2:28 PM
    Moderator
  • Some years ago I developed this VBScript program to run any executable on a group of remote computers:

    http://www.rlmueller.net/Deploy.htm

    The script works on all computers in a group. It first pings each to check if they are available. If the computer responds, the script copies the executable to the C: drive on the remote computer, and runs the program. Finally, the script deletes the executable from the remote computer. The script maintains a detailed log of all activity.


    Richard Mueller - MVP Directory Services

    Wednesday, March 14, 2012 3:08 PM
    Moderator

All replies

  • Hi,

    You are attempting to connect remotely to a network resource from WMI using DCOM impersonation. This is tricky to get working properly.

    My usual solutions are to either: 1) copy the executable to the remote computer first, or 2) use the task scheduler to run the program.

    Bill

    Wednesday, March 14, 2012 2:28 PM
    Moderator
  • Some years ago I developed this VBScript program to run any executable on a group of remote computers:

    http://www.rlmueller.net/Deploy.htm

    The script works on all computers in a group. It first pings each to check if they are available. If the computer responds, the script copies the executable to the C: drive on the remote computer, and runs the program. Finally, the script deletes the executable from the remote computer. The script maintains a detailed log of all activity.


    Richard Mueller - MVP Directory Services

    Wednesday, March 14, 2012 3:08 PM
    Moderator
  • Dear Sir,

    I think I used your script to install the hotfix which replaces the standard Windows Installer 3.1 with the Installer 4.5 on my XP machines and this works perfectly.

    Therefore my thank.


    Benny.

    Monday, March 19, 2012 8:09 AM
  • I wish additional to install Office 2010 from a network share, so I think afther the post of AbqBill I should go for a scheduled task.

    Do you think that is possible or should I go for another solution?


    Benny.

    Monday, March 19, 2012 8:10 AM
  • Hi,

    IMO, a scheduled task is probably the simplest way unless you have an alternative mechanism that is designed for software distribution (e.g., a software installation GPO, a systems management suite, etc.).

    Bill

    Monday, March 19, 2012 6:45 PM
    Moderator
  • Office is best installed from Software Distribution.  You will have to create a transform for it .  Follow the instructions in the setup help file on the CD/DVD.

    None of any of this has anything to do with scripting.  You should post in the WIndows Office 2010 admin forums or the WIndoes Group Policy forum.

    You cannot access a share with a remote script under any circumstances without altering the overall security of teh system and teh network.  This is by design.  Certain things like patch installation can never be done from a share remotely.  The Microsoft patch file (KB or SP) must reside on teh remote system physical drive.  Patches cannot be distributed via GPO.

    To distribute patches remotely it is easiest and best to use WSUS.

    To distribute Office you willneed to create a setup that can autmatically enter the key and authorizations.  Tis must be done not matter how yuo install it.  No GUI thena trnsform must be used.

    The Microsoft Office site has more information about installation of Office with GP and on a Terminal Server.

    Start here -> http://technet.microsoft.com/en-us/library/ff602181.aspx


    ¯\_(ツ)_/¯

    Monday, March 19, 2012 8:11 PM