+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
Windows Thread, VBS Script Syntax Check in Technical; I have found a very simple VBS script to register a DLL file that has become unregistered: Code: Set oShell ...
  1. #1

    Join Date
    Feb 2009
    Location
    Essex
    Posts
    225
    Thank Post
    22
    Thanked 16 Times in 12 Posts
    Rep Power
    14

    VBS Script Syntax Check

    I have found a very simple VBS script to register a DLL file that has become unregistered:

    Code:
    Set oShell = CreateObject("Wscript.Shell")
    oShell.Run "RegSvr32 /s " & chr(34) & "%ProgramFiles%\Internet Explorer\ieproxy.dll" & chr(34)
    If I want to register more than one DLL file in the same VB Script do I need to repeat both lines, or just the second one?

    E.g. Will this work:

    Code:
    Set oShell = CreateObject("Wscript.Shell")
    oShell.Run "RegSvr32 /s " & chr(34) & "%ProgramFiles%\Internet Explorer\ieproxy.dll" & chr(34) 
    oShell.Run "RegSvr32 /s " & chr(34) & "%ProgramFiles(x86)%\Internet Explorer\ieproxy.dll" & chr(34)
    Or does it need to look like this?

    Code:
    Set oShell = CreateObject("Wscript.Shell")
    oShell.Run "RegSvr32 /s " & chr(34) & "%ProgramFiles%\Internet Explorer\ieproxy.dll" & chr(34)
    Set oShell = CreateObject("Wscript.Shell")
    oShell.Run "RegSvr32 /s " & chr(34) & "%ProgramFiles(x86)%\Internet Explorer\ieproxy.dll" & chr(34)

  2. #2

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,697
    Thank Post
    335
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    First one. It's just basically setting a variable, should only need to change if if the object changes.

    Steve

  3. #3
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    5,013
    Thank Post
    120
    Thanked 282 Times in 260 Posts
    Rep Power
    108
    The first one is fine you can reuse the oShell object.

  4. #4

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,789
    Thank Post
    3,296
    Thanked 1,054 Times in 975 Posts
    Rep Power
    365
    @Steve21

    How does that vbs work with the environment variable. Ive always had to use the expand environment variable command to make it return the correct info for the path etc

  5. #5
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    5,013
    Thank Post
    120
    Thanked 282 Times in 260 Posts
    Rep Power
    108
    Quote Originally Posted by mac_shinobi View Post
    @Steve21

    How does that vbs work with the environment variable. Ive always had to use the expand environment variable command to make it return the correct info for the path etc
    This is correct I missed that too ! It will need expanding first.

  6. #6

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,789
    Thank Post
    3,296
    Thanked 1,054 Times in 975 Posts
    Rep Power
    365
    Quote Originally Posted by ChrisH View Post
    This is correct I missed that too ! It will need expanding first.
    Prolly easier to make a bat file to register or un-register each / all of the relevant dll / ocx file types as you don't need to use the expandenviromentvariable command. If you wanted a vbscript to do it ( if you can post back with a list of dll file names and there full path(s)

    I can post back with a script to do that unless @Steve21 or @ChrisH beat me to it

  7. #7


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    9,035
    Thank Post
    231
    Thanked 2,700 Times in 1,994 Posts
    Rep Power
    792
    Would this work?

    Code:
    On Error Resume Next
    
    Dim strPFx86,strPFx64
    
    Set oShell = Wscript.CreateObject("Wscript.Shell")
    strPFx64 = oShell.ExpandEnvironmentStrings("%ProgramFiles%")
    strPFx86 = oShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")
    
    oShell.Run "RegSvr32 /s " & chr(34) & strPFx64 & "\Internet Explorer\ieproxy.dll" & chr(34) 
    oShell.Run "RegSvr32 /s " & chr(34) & strPFx86 & "\Internet Explorer\ieproxy.dll" & chr(34)

  8. 2 Thanks to Arthur:

    CommodoreS (12th June 2013), mac_shinobi (12th June 2013)

  9. #8

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,789
    Thank Post
    3,296
    Thanked 1,054 Times in 975 Posts
    Rep Power
    365
    Quote Originally Posted by Arthur View Post
    Would this work?

    Code:
    On Error Resume Next
    
    Dim strPFx86,strPFx64
    
    Set oShell = Wscript.CreateObject("Wscript.Shell")
    strPFx64 = oShell.ExpandEnvironmentStrings("%ProgramFiles%")
    strPFx86 = oShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")
    
    oShell.Run "RegSvr32 /s " & chr(34) & strPFx64 & "\Internet Explorer\ieproxy.dll" & chr(34) 
    oShell.Run "RegSvr32 /s " & chr(34) & strPFx86 & "\Internet Explorer\ieproxy.dll" & chr(34)
    Do you even have to ask, 99.9% of the stuff you post or suggest works lol

  10. #9

    Join Date
    Feb 2009
    Location
    Essex
    Posts
    225
    Thank Post
    22
    Thanked 16 Times in 12 Posts
    Rep Power
    14
    The other two I need to register are:

    Code:
    oShell.Run "RegSvr32 /s " & chr(34) & "%SystemRoot%\System32\actxprxy.dll" & chr(34)
    oShell.Run "RegSvr32 /s " & chr(34) & "%WinDir%\SysWOW64\actxprxy.dll" & chr(34)
    Re-registering these two (four - as two are for 32 bit and two are for 64 Bit) solves an issue where double clicking on a Windows Explorer folder will cause it to open in a new window - even if the explorer settings are set to tell it not do so.

    Although I also have a 2Simple OCX/DLL problem elsewhere and think I can work out from this how to adapt the VBS script to fix the issue there.

    I probably could use a Batch file - but guessing the VBS file will do the same thing - as long as I place it in a Computer Configuration startup script in the AD.
    Last edited by CommodoreS; 12th June 2013 at 04:25 PM.

  11. #10

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,789
    Thank Post
    3,296
    Thanked 1,054 Times in 975 Posts
    Rep Power
    365
    Something like this :

    Code:
    On Error Resume Next
    
    Dim strPFx86,strPFx64, winx86, winx64
    
    Set oShell = Wscript.CreateObject("Wscript.Shell")
    strPFx64 = oShell.ExpandEnvironmentStrings("%ProgramFiles%")
    strPFx86 = oShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")
    winx86 = oShell.ExpandEnvironmentStrings("%SystemRoot%")
    winx64 = oShell.ExpandEnvironmentStrings("%WinDir%")
    
    oShell.Run "RegSvr32 /s " & chr(34) & strPFx64 & "\Internet Explorer\ieproxy.dll" & chr(34) 
    oShell.Run "RegSvr32 /s " & chr(34) & strPFx86 & "\Internet Explorer\ieproxy.dll" & chr(34)
    oShell.Run "RegSvr32 /s " & chr(34) & winx86 & "\System32\actxprxy.dll" & chr(34)
    oShell.Run "RegSvr32 /s " & chr(34) & winx64 & "\SysWOW64\actxprxy.dll" & chr(34)
    Might want to test this on one client by running the script manually on the client first to make sure it does work correctly without errors, possibly comment out the on error resume next line though

  12. Thanks to mac_shinobi from:

    CommodoreS (13th June 2013)

  13. #11

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,789
    Thank Post
    3,296
    Thanked 1,054 Times in 975 Posts
    Rep Power
    365
    Not related to the script but just a quick question to @Arthur

    Would it make any difference between this :


    Set oShell = Wscript.CreateObject("Wscript.Shell")

    OR This

    Set oShell = CreateObject("Wscript.Shell")

  14. #12

    Join Date
    Feb 2009
    Location
    Essex
    Posts
    225
    Thank Post
    22
    Thanked 16 Times in 12 Posts
    Rep Power
    14
    Quote Originally Posted by mac_shinobi View Post
    Something like this :

    Code:
    On Error Resume Next
    
    Dim strPFx86,strPFx64, winx86, winx64
    
    Set oShell = Wscript.CreateObject("Wscript.Shell")
    strPFx64 = oShell.ExpandEnvironmentStrings("%ProgramFiles%")
    strPFx86 = oShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")
    winx86 = oShell.ExpandEnvironmentStrings("%SystemRoot%")
    winx64 = oShell.ExpandEnvironmentStrings("%WinDir%")
    
    oShell.Run "RegSvr32 /s " & chr(34) & strPFx64 & "\Internet Explorer\ieproxy.dll" & chr(34) 
    oShell.Run "RegSvr32 /s " & chr(34) & strPFx86 & "\Internet Explorer\ieproxy.dll" & chr(34)
    oShell.Run "RegSvr32 /s " & chr(34) & winx86 & "\System32\actxprxy.dll" & chr(34)
    oShell.Run "RegSvr32 /s " & chr(34) & winx64 & "\SysWOW64\actxprxy.dll" & chr(34)
    Might want to test this on one client by running the script manually on the client first to make sure it does work correctly without errors, possibly comment out the on error resume next line though
    I think strPFx64 andstrPFx86 are pointing to the wrong directories - should not matter for this, but may do if others modify this to register other files. ProgramFiles(x86) is normally seen on x64 systems and ProgramFiles on x86 systems.

    Also not had a chance to test this yet (need to find another system which has this problem, as it now seems a bit random) - but also not sure if the spaces between the DIM variables will make any difference.

  15. #13

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,789
    Thank Post
    3,296
    Thanked 1,054 Times in 975 Posts
    Rep Power
    365
    1. You will need to adjust the variables / paths so they point to the correct paths for the relevant files ( where ever the files are actually located ) that you are trying to register / un-register etc. So that way each path is the full path to where the file(s) in question are.

    2. No the spaces are just ignored, so if you want you could delete the spaces between the variables, as long as there is a comma between each of the variable names ie

    var1,var2 versus var1 , var2

  16. Thanks to mac_shinobi from:

    CommodoreS (13th June 2013)

  17. #14


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    9,035
    Thank Post
    231
    Thanked 2,700 Times in 1,994 Posts
    Rep Power
    792
    Quote Originally Posted by CommodoreS View Post
    I think strPFx64 and strPFx86 are pointing to the wrong directories
    They're not (if you are using a 64-bit OS).

    strPFx64 = %ProgramFiles% because that's where 64-bit programs get installed.
    strPFx86 = %ProgramFiles(x86)% because that's where 32-bit programs get installed.

    Obviously, the "Program Files (x86)" folder and variable only exists on 64-bit windows OSs, so you could perform an additional check before trying to register the DLL file. You could also rename strPFx64 to strPF.

    Quote Originally Posted by CommodoreS View Post
    not sure if the spaces between the DIM variables will make any difference.
    @mac_shinobi is right. It doesn't make any difference.
    Last edited by Arthur; 13th June 2013 at 05:06 PM.

  18. 2 Thanks to Arthur:

    CommodoreS (13th June 2013), mac_shinobi (13th June 2013)

  19. #15

    Join Date
    Feb 2009
    Location
    Essex
    Posts
    225
    Thank Post
    22
    Thanked 16 Times in 12 Posts
    Rep Power
    14
    Quote Originally Posted by Arthur View Post
    They're not (if you are using a 64-bit OS).

    strPFx64 = %ProgramFiles% because that's where 64-bit programs get installed.
    strPFx86 = %ProgramFiles(x86)% because that's where 32-bit programs get installed.

    Obviously, the "Program Files (x86)" folder and variable only exists on 64-bit windows OSs, so you could perform an additional check before trying to register the DLL file. You could also rename strPFx64 to strPF.
    Sorry I meant on 32 bit OSs which the OSs still are (I guess this can be looked at in two ways and I have looked at it the other way) - I want to add the 64 bit stuff for futureproofing though. I will just leave it as is

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 4
    Last Post: 7th May 2013, 12:25 PM
  2. Replies: 7
    Last Post: 16th December 2011, 05:54 AM
  3. Replies: 4
    Last Post: 25th December 2006, 09:15 PM
  4. VB Script ti check for folder and then copy contents to PC
    By tosca925 in forum How do you do....it?
    Replies: 4
    Last Post: 2nd October 2006, 08:15 PM
  5. VBS script for prestaging computers anyone?
    By ChrisH in forum Scripts
    Replies: 7
    Last Post: 23rd June 2006, 09:59 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •