Re: Copying and running processes on remote machines

From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 02/15/05


Date: Tue, 15 Feb 2005 11:49:07 +0100

Amit M. wrote:

> First off, there is nothing sinister here...I am trying to create
> a basic remote installer, and I need to know how to do 2 things:
>
> 1. Copy files to a remote machine (on the same domain). I know I
> can do something like use scripting to copy to c$..but I was
> wondering if there is a better way.

That's the best way if you want to do it remotely.

If this is AD domain computers I personally would have installed in a
startup script (with a GPO) that runs as part of the boot up process
(before the user logs in). It runs under the system context and has
admin rights.

Something like this with a VBScript based startup script:

'--------------------8<----------------------
' MDAC silent install, no reboot/reboot prompt
sCommand = "\\server\share\inst\mdac_typ.exe /q:a /c:""dasetup /q /n"""
Set oShell = CreateObject("WScript.Shell")
oShell.Run sCommand, 1, True
'--------------------8<----------------------

To be able to access files over the network from the computer startup
script, you could put the file(s) on a network share and grant read
access for the AD group "Domain Computers" to the share.

Alternatively, from the startup script, you could map a drive on
the fly, like this:

sDomainUser = "arp.corp\computer_fix"
sPswd = "something"
Set oNetwork = CreateObject("Wscript.Network")
oNetwork.MapNetworkDrive _
         "Y:", "\\server\netlogon\some folder",, sDomainUser, sPswd

To avoid reinstalling MDAC at every computer startup, check if same
or newer version is already installed and only install if not.:

WScript.Echo GetAdoVersion

Function GetAdoVersion()
   ' Will return 0 if oADO.Version "fails"
   GetAdoVersion = 0
   On Error Resume Next
   Set oADO = CreateObject("ADODB.Connection")
   GetAdoVersion = oADO.Version
End Function

For other ways to detect the ADO version, take a look here at this ADO FAQ:

Q20) How do I determine, through code, what version of MDAC is
installed on a computer???
http://www.able-consulting.com/ADO_Faq.htm#Q20

> 2. Execute an exe on a remote machine. Basically, when I copy
> the files I need to the remote pc, I need to execute some exe's
> (in this case, the MDAC installer).

'--------------------8<----------------------
' create a process with WMI on local or remote computer

sComputer = "." ' use "." for local computer
sCommand = "c:\inst\mdac_typ.exe /q:a /c:""dasetup /q /n"""

Set oWMI = GetObject("winmgmts:" _
              & "{impersonationLevel=impersonate}!\\" _
              & sComputer & "\root\cimv2")

iRC = oWMI.Get("Win32_Process").Create(sCommand, Null, Null, iProcessID)

' iRC will indicate if the app was successfully launched or not
If iRC = 0 Then
    WScript.Echo "Application started"
Else
    WScript.Echo "Could not start application!"
End If
'--------------------8<----------------------

Silent install, no reboot/reboot prompt:

mdac_typ.exe /q:a /c:"dasetup /q /n"

Frequently asked questions about MDAC 2.6 Setup and about MDAC 2.7
Setup (goes for MDAC 2.8 as well)
http://support.microsoft.com/default.aspx?scid=kb;en-us;842193

HOWTO: Invoke Silent MDAC or DA SDK 2.0 Redistribution
http://support.microsoft.com/default.aspx?scid=KB;en-us;192009

-- 
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx


Relevant Pages

  • Re: MDAC-Patch (MS04-003)
    ... > "An error occurred while setup was trying to verify the ... Download and install one of the following and see if it helps: ... MDAC 2.7 Service Pack 1 Refresh ... Microsoft MVP Scripting and WMI, ...
    (microsoft.public.windowsxp.security_admin)
  • RE: Script to echo files based on specific dates
    ... "Walid" wrote: ... WinXP Pro on my workstation so I believe I have to install it on my machine, ... does the remote server that I query by the poweshell command ... I am pretty new to scripting. ...
    (microsoft.public.windows.server.scripting)
  • Re: Windows Script Host Error 1619
    ... > however I am gettinga an error 1619 when trying to install it on a remote ... specify the Kerberos protocol in your WMI binding string. ... Install Software on a Remote Computer ... Microsoft MVP Scripting and WMI, ...
    (microsoft.public.windows.server.scripting)
  • Re: Win2000 Professional with automatic update. (KB832483)
    ... >will not install. ... >I suggest you upgrade to MDAC 2.8 and see if it solves ... >Microsoft MVP Scripting and WMI, ...
    (microsoft.public.windowsupdate)
  • Re: Invalid install parameters /q:u /r:n - MDAC 03-033
    ... > at the end - we have no control of how this install is done. ... MDAC installations as well as MDAC hotfixes always need this as well on the ... Microsoft MVP Scripting and WMI, ...
    (microsoft.public.security)

Loading