Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Register a OCX file with a vbscript.

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,28284
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Register a OCX file with a vbscript.
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Register a OCX file with a vbscript. - 11/23/2005 5:18:29 AM   
  Woodzter

 

Posts: 57
Score: 0
Joined: 10/25/2005
Status: offline
I need to register a OCX file, I havefound out on the below how to do it but would like to do it in a vbscript. Is there anyway the below could be put into a vbscrip to enable this to be done?

if you are receiving errors about an ocx file, registering the file may solve the problem. To register an ocx file simply follow the simple steps below.

1.Locate the file using windows explorer or My Computer. Alternatively search for the filename.

2.Hold down the shift key and right click on the file. Then click 'Open With...' from the menu.

3.An 'Open With' dialog box should appear. Click the button 'Other...'.

4.Navigate to your windows\system32 directory and select the file 'RegSvr32.exe'. Do a file search for it if you have trouble locating the exact folder. On Windows 2000 it is typically located in c:\WINNT\System32. Click Open to select the file. Then click OK on the 'Open With' dialog.

5.You should see a message indicating the file was successfully registered. If you see an error message, try restarting your computer and going through the above process again.

or
Go to the Run item on the Start menum, and type:
regsvr32 <path & filename of dll or ocx>
 
 
Post #: 1
 
 RE: Register a OCX file with a vbscript. - 11/23/2005 6:26:31 AM   
  Country73


Posts: 712
Score: 8
Joined: 8/25/2004
From: USA
Status: offline
This shouldn't be too difficult with vbscript.
First you'll need to write in the code to search for the file itself. There have been several posts out here for locating files, so I would suggest you search for that first; once you've located the code for locating your file you can then use this bit to register the file:

Set oShell = CreateObject("Wscript.Shell")
oShell.Run "RegSvr32 /s " & chr(34) & "Path\to\file.ocx" & chr(34)

RegSvr32 switches
 
/u = Unregister server
/s = Silent; display no message boxes
/i = Call DllInstall passing it an optional [cmdline]; when used with /u calls dll uninstall
/n = do not call DllRegisterServer; this option must be used with /i
 
chr(34)
 
Used to add extra set of quotes " around a string. Used when passing to a cmdline or when there are spacing in the path you are using.

(in reply to Woodzter)
 
 
Post #: 2
 
 RE: Register a OCX file with a vbscript. - 11/23/2005 8:03:33 AM   
  Woodzter

 

Posts: 57
Score: 0
Joined: 10/25/2005
Status: offline
Do i need to use the locate file bit?

I know the file exists because i have copied it over in a script

(in reply to Country73)
 
 
Post #: 3
 
 RE: Register a OCX file with a vbscript. - 11/23/2005 8:52:30 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
If you know th file is there then you do not need to do the locate file part. Just do as Country 73 suggested and use the path and name of the ocx that you copied over.

(in reply to Woodzter)
 
 
Post #: 4
 
 RE: Register a OCX file with a vbscript. - 11/23/2005 8:57:39 AM   
  Woodzter

 

Posts: 57
Score: 0
Joined: 10/25/2005
Status: offline
Thanks guys for all your help.

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: Register a OCX file with a vbscript. Follow Up How-... - 9/18/2006 11:26:16 PM   
  stephen.wolfe

 

Posts: 69
Score: 0
Joined: 8/9/2005
From: Tampa, FL
Status: offline
After using the 'search' function of the forum I found this smal thread on registering a DLL or OCX, great piece of code, works fine.
However, since I have to do this on 1,100 machines is there a way to check to see if the registration actually occured?

TIA,

Steve

_____________________________

Steve

(in reply to Country73)
 
 
Post #: 6
 
 RE: Register a OCX file with a vbscript. Follow Up How-... - 9/18/2006 11:54:40 PM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Not a quick and simple way that I know of. What you can do is use something like Regmon or Advanced Registry Trace to determine what registry changes happen when the file is registered then check the machines for those registry indicators.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to stephen.wolfe)
 
 
Post #: 7
 
 RE: Register a OCX file with a vbscript. Follow Up How-... - 9/19/2006 12:21:16 AM   
  stephen.wolfe

 

Posts: 69
Score: 0
Joined: 8/9/2005
From: Tampa, FL
Status: offline
Thanks for the pointer ...

Steve

_____________________________

Steve

(in reply to ebgreen)
 
 
Post #: 8
 
 RE: Register a OCX file with a vbscript. Follow Up How-... - 8/10/2007 5:15:29 AM   
  ckarlson

 

Posts: 1
Score: 0
Joined: 8/10/2007
Status: offline
How would you write this in VB.Net as we cant use Set? 

< Message edited by ckarlson -- 8/10/2007 5:22:49 AM >

(in reply to stephen.wolfe)
 
 
Post #: 9
 
 RE: Register a OCX file with a vbscript. Follow Up How-... - 8/10/2007 5:32:45 AM   
  CondoPC


Posts: 118
Score: 0
Joined: 7/23/2007
Status: offline
As for whether it is registered or not, couldn't you just try to activate the component? If you can, it registered, otherwise it didn't.

Also, we have a "Send To" shortcut for "unregister" (regsvr32 -u) and register (regsvr32) so that a user can right click on a file and send it to the shortcut.


This seems to be focused around a support function for the application. Wouldn't it make sense to write a support application that could be accessed from the help menu that would verify file registration (activate a component) and register it if missing? Or even in the worse case, just reregister the component anyways. Something like "Repair application files". If it is a helpdesk doing support for users not withtin the organization, would sending them a vbscript file be an acceptable solution? I know that in my company, that would be a definite no-go.

(in reply to stephen.wolfe)
 
 
Post #: 10
 
 RE: Register a OCX file with a vbscript. Follow Up How-... - 8/10/2007 5:39:57 AM   
  ehvbs

 

Posts: 2078
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi ckarlson,

as this is a VBScript Forum, have a look at

http://msdn2.microsoft.com/en-us/library/fy81t8yk(VS.80).aspx
http://msdn2.microsoft.com/en-us/library/system.diagnostics.process.start(VS.80).aspx
http://msdn2.microsoft.com/en-us/library/53ezey2s(VS.80).aspx

(in reply to CondoPC)
 
 
Post #: 11
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Register a OCX file with a vbscript. Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts