Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Register dll or component on remote machine 1

Status
Not open for further replies.

snotmare

Programmer
Jan 15, 2004
262
US
Hello!

Does anyone know how to register a dll or component on a remote machine? I know you can use regsvr32.exe and invoke it like this...
Code:
Dim objShell

Set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run "regsvr32.exe /u C:\test.wsc"
Set objShell = Nothing
... but is there a way to do the same thing on a remote machine? Can I make a shell reference to a remote machine?

Thanks all!

He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive. - King Solomon
 
By remote machine, do you mean: (Assume Machine 1 is local and Machine 2 is remote)



A) Windows on Machine 1 creates the object from a file shared by Machine 2

or

B) Windows on Machine 2 creates the object from a file that is local to Machine 2, but it was configured to behave this way by Machine 1


???

 
Good questions, let me clarify...

I'm on machine1. The dll I'm registering is already on machine2. I want to invoke a register command from machine1 to register the dll on machine2. Machine1 knows the path of the dll on machine2.

Also, the dll that I want to register on machine2 is on a shared drive with machine1.

If you need more information, let me know. I would be much appreciative if I can get this to work.

Any ideas?

He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive. - King Solomon
 
I believe you need to have the REGSVR32 execute locally. I would suggest using PSEXEC from Sysinternals. You can easily script it to run against multiple machines if needed.

I hope you find this post helpful.

Regards,

Mark
 
Thanks markdmac for the response!

It's time to go home, but I will research this more tomorrow. Do you have any working examples of using PSEXEC or other ways to register dlls on remote machines?

Thank you much!

He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive. - King Solomon
 
You will want to use the PSEXEC like this:

First create vbscript or a simple batch file that does your command.
For example:
Code:
REGSVR32 C:\Windows\System32\wuaueng.dll

Now create a list of machines to run against. Call it WSLIST.TXT.

Create a vbscript file to connect to each machine in wslist.txt and execute the bat file.

Code:
'==========================================================================
'
' VBScript Source File -- 
'
' NAME: RemoteDfix.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL   : [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 12/10/2002
'
' COMMENT: 
'
'==========================================================================
On Error Resume Next

'open the file system object
Set oFSO = CreateObject("Scripting.FileSystemObject")
set WSHShell = wscript.createObject("wscript.shell")
'open the data file
Set oTextStream = oFSO.OpenTextFile("wslist.txt")
'make an array from the data file
RemotePC = Split(oTextStream.ReadAll, vbNewLine)
'close the data file
oTextStream.Close

For Each strWorkstation In RemotePC
'Do something useful with strWorkstation

If Not oFSO.FolderExists("\\"&strWorkstation&"\e$\Software\Workstation\Scripts") Then 
	Call WSHShell.Run("cmd.exe /C md \\" & strWorkstation & "\e$\Software\Workstation\Scripts")
End If

If Not oFSO.FileExists("\\"&strWorkstation&"\e$\Software\Workstation\Scripts\regsvrdll.bat") Then 
Call WSHShell.Run("cmd.exe /C copy C:\AssignD.vbs \\"&strWorkstation&"\e$\Software\Workstation\Scripts")
End If
wscript.sleep 200
If Not oFSO.FileExists("\\"&strWorkstation&"\c$\psexec.exe") Then 
	Call WSHShell.Run("cmd.exe /C copy C:\psexec.exe \\"&strWorkstation&"\c$")
End If
wscript.sleep 200
Call WSHShell.Run("cmd.exe /c c:\psexec.exe \\" & strWorkstation & " -s -i cmd.exe /C E:\Software\Workstation\Scripts\regsvrdll.bat")		
Next

Set oFSO = Nothing
Msgbox "All done"
WScript.Quit(0)

I hope you find this post helpful.

Regards,

Mark
 
Hey Markdmac, thank you for your input, it worked! I just have to convince the network gods to allow this, so I may hit a wall there anyways :).

I do have one question about it... after I run the script that invokes psexec, the script executes successfully, but a bat window is still displayed with the psexec logo. I took away the '-i' because I thought that would take care of it (per the documentation on the website), but it didn't. Any thoughts of how to get this window to not display?

Thanks!

He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive. - King Solomon
 
We are using the /C with the CMD command, so that SHOULD make it go away. Sorry, can't be of further assistance.

I hope you find this post helpful.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top