Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Batch file request ...

06 Nov 2012   #1

windows 7 x64
 
 
Batch file request ...

Hello,

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.

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 System SpecsSystem Spec
.

06 Nov 2012   #2

Windows 7 Ultimate x64
 
 

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 System SpecsSystem Spec
06 Nov 2012   #3

Windows 7 32 bit
 
 

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 System SpecsSystem Spec
.


07 Nov 2012   #4

Windows 7 Ultimate x64
 
 

Quote   Quote: Originally Posted by MilesAhead View Post
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 System SpecsSystem Spec
07 Nov 2012   #5

Windows 7 32 bit
 
 

Quote:
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 Windows 7.
My System SpecsSystem Spec
07 Nov 2012   #6

x64 (6.3.9600) Win8.1 Pro & soon dual boot x64 (6.1.7601) Win7_SP1 HomePrem
 
 

parsing the output of the ver command will tell you whether you're on XP or Windows 7
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 System SpecsSystem Spec
08 Nov 2012   #7

Windows 7 32 bit
 
 

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 System SpecsSystem Spec
08 Nov 2012   #8

x64 (6.3.9600) Win8.1 Pro & soon dual boot x64 (6.1.7601) Win7_SP1 HomePrem
 
 

Beats a clunky batch file.
Quote   Quote: Originally Posted by MilesAhead View Post
My System SpecsSystem Spec
08 Nov 2012   #9

Windows 7 32 bit
 
 

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 System SpecsSystem Spec
Reply

 Batch file request ...




Thread Tools




Our Sites

Site Links

About Us

Find 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 06:02 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33