Batch file request ...


  1. Posts : 1
    windows 7 x64
       #1

    Batch file request ...


    Hello,

    I need bat file to detect xp or win7 (32 or 64) and then to copy
    ocx and dll files to appropriate system windir and afther copy to register them.

    my ocx files are in folder named OCX, and bat file is in main dir C:\SomeDir

    This is my bat file for register ocx files, but I dont know how to copy them and
    how to determine what OS is it, 32 or 64, System32 or SYSWOW64 ...

    Code:
    @echo off
    cls
    Title MasteRG 2010-2012
    echo.
    echo.
    echo  Installing ocx/dll files !
    echo.
    echo   Close all running programs
    echo   MasteRG (c) 2010-2012 
    echo.
    echo   Install will now start...
    echo.
    pause
    cls
    echo.
    echo.
    echo                Instaling...
    echo   ----------------------------------
    echo   Progress: ŰŰ۲˛˛˛˛˛˛˛˛˛˛˛˛˛˛˛˛ 15%%
    %systemroot%\System32\regsvr32.exe C:\Windows\System32\Button3D.ocx -s
    cls
    echo.
    echo.
    echo                Installing...
    echo   ----------------------------------
    echo   Progress: ŰŰŰŰŰŰ۲˛˛˛˛˛˛˛˛˛˛˛˛ 30%%
    %systemroot%\System32\regsvr32.exe C:\Windows\System32\Button3D.ocx -s
    cls
    echo.
    echo.
    echo                Installing...
    echo   ----------------------------------
    echo   Progress: ŰŰŰŰŰŰŰŰŰŰ۲˛˛˛˛˛˛˛˛ 55%%
    %systemroot%\System32\regsvr32.exe C:\Windows\System32\MSCOMCTL.OCX -s
    cls
    echo.
    echo.
    echo                Installing...
    echo   ----------------------------------
    echo   Progress: ŰŰŰŰŰŰŰŰŰŰŰŰŰ۲˛˛˛˛˛ 65%%
    %systemroot%\System32\regsvr32.exe C:\Windows\System32\MSWINSCK.OCX -s
    cls
    echo.
    echo.
    echo                Installing...
    echo   ----------------------------------
    echo   Progress: ŰŰŰŰŰŰŰŰŰŰŰŰŰŰ۲˛˛˛˛ 70%%
    %systemroot%\System32\regsvr32.exe C:\Windows\System32\RICHTX32.OCX -s
    cls
    echo.
    echo.
    echo                Installing...
    echo   ----------------------------------
    echo   Progress: ŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰ۲˛˛˛ 75%%
    %systemroot%\System32\regsvr32.exe C:\Windows\System32\actskin4.ocx -s
    cls
    echo.
    echo.
    echo                Installing...
    echo   ----------------------------------
    echo   Progress: ŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰ۲˛ 90%%
    %systemroot%\System32\regsvr32.exe C:\Windows\System32\COMDLG32.OCX -s
    cls
    echo.
    echo.
    echo                Installing...
    echo   ----------------------------------
    echo   Progress: ŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰ 100%%
    %systemroot%\System32\regsvr32.exe C:\Windows\System32\MSCOMM32.OCX -s
    
    cls
    echo.
    echo.
    echo   Installation was completed!
    echo.
    echo   Bye bye!
    echo.
    echo.
    pause
      My Computer


  2. Posts : 2,468
    Windows 7 Ultimate x64
       #2

    Here is a possible way:
    Code:
    @@echo off
    
    if exist %windir%\syswow64\nul goto x64
    
    :x86
    set systempath=%windir%\system32
    goto register
    
    :x64
    set systempath=%windir%\syswow64
    goto register
    
    :register
    echo %systempath%
    set systempath=
    
    pause
    In short, it simply checks for existence of SysWOW64, which is present on x64 system but not on x86. From there it just sets a variable to the proper target path and then jumps to the installation code, which does the work on that target path (here just print it, but the real work goes there).
    Note that for what I've written I'm assuming that all DLLs and OCXs are 32 bits libraries. In x86 systems they obviously go to system32, but on x64 should og to syswow64. But if any library is x64, on x64 OSs they must go to system32 and fail on x86.
    Of course, you need to run the bat file under an admin account for it to succeed.
      My Computer


  3. Posts : 5,092
    Windows 7 32 bit
       #3

    I don't think there's a dependable way to get the Windows version from standard batch(not powershell.)

    If all you need to know is 32 vs. 64 bit checking SysWow64 is fine. But if you need to copy one dll or ocx if it's XP and another if it's Windows 7 you're probably better off using a scripting language like AutoHotkey_L, AutoIt3 or VBScript. I don't do that much with VBScript but I know ahk_l and autoit have the means to call Winapi functions via DllCall to get the exact windows version number. Like 5.1 should be XP, 6.0 is Vista and 6.1 is Windows Seven. I dunno' what Windows 8 is.
      My Computer


  4. Posts : 2,468
    Windows 7 Ultimate x64
       #4

    MilesAhead said:
    I dunno' what Windows 8 is.
    It's 6.2, the very same as Win 2012 too.

    Since the OP only requested 32/64 bits, checking for SysWOW64 should suffice (quick and dirty way, but works), but he never cared about the version anyway in his post.
      My Computer


  5. Posts : 5,092
    Windows 7 32 bit
       #5

    I need bat file to detect xp or Windows 7 (32 or 64) and then to copy
    ocx and dll files to appropriate system windir and afther copy to register them.
    Maybe you should read the part of the original post that mentions xp detection? Granted he didn't put it in caps.

    Some ocx that work in XP may not work so well in W7.
      My Computer


  6. Posts : 6,458
    x64 (6.3.9600) Win8.1 Pro & soon dual boot x64 (6.1.7601) Win7_SP1 HomePrem
       #6

    parsing the output of the ver command will tell you whether you're on XP or Win7
    checking for SYSWOW64 will tell you the bitwise

    set variables based on the above to make your other tasks easier

    but you'll have to do the work and testing - I think you're up to it.
    Read about conditional testing, piping (|) and redirecting output (<>) if you need to brush up (I know I have to)
      My Computer


  7. Posts : 5,092
    Windows 7 32 bit
       #7

    Is this requirement to use batch something you can't get around? For what you are doing Inno Setup would probably be perfect. It can register COM dll and ocx and also I believe you can specify if the COM stuff should be unregistered and removed during uninstall. For stuff you can't do with the built in macros, it has a Pascal scripting language. It's free and you can even get free skins for the installer Gui.

    I used it quite a bit until it became the fad for everything to be "portable." Now I just zip stuff up. Even if you don't use it on this job it's a good tool to have.

    Inno Setup
      My Computer


  8. Posts : 6,458
    x64 (6.3.9600) Win8.1 Pro & soon dual boot x64 (6.1.7601) Win7_SP1 HomePrem
       #8

    Beats a clunky batch file.
    MilesAhead said:
      My Computer


  9. Posts : 5,092
    Windows 7 32 bit
       #9

    Inno has been around a long time. Kind of like the guy's life's work. It's not likely to go away any time soon, barring calamity. :)
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 01:52.
Find Us