Batch file request ...

MasteRG

New member
Local time
1:20 AM
Messages
1
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

OS
windows 7 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 Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Sattelite A665-S6092
OS
Windows 7 Ultimate x64
CPU
Intel Core i7-740QM
Memory
8 GB DDR3
Graphics Card(s)
NVIDIA GeForce 330GT
Screen Resolution
1366x768
Hard Drives
Samsung 840 SSD 500GB
1TB USB3 external HD
Cooling
Coolermaster Notepal U3 notebook cooling pad
Internet Speed
3mbps ASDL
Antivirus
ClamWin 0.98.7
Browser
Opera 12.17 x86 (main), Firefox 38 (sec), IE11 (last resort)
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

Computer Manufacturer/Model Number
HP Media Center
OS
Windows 7 32 bit
CPU
AMD 5200+ dual core
Memory
2 GB
Graphics Card(s)
NVidia GeForce 6150SE 128 MB
Monitor(s) Displays
CRT
Screen Resolution
1280x1024
Hard Drives
500 GB Sata internal :

SIIG USB 3.0 docking stations w/WD Caviar Black 6 Gb/s drives
Keyboard
PS/2
Mouse
PS/2 Wheel Mouse
Other Info
SIIG USB 3.0 PCIexpress card.
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

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Sattelite A665-S6092
OS
Windows 7 Ultimate x64
CPU
Intel Core i7-740QM
Memory
8 GB DDR3
Graphics Card(s)
NVIDIA GeForce 330GT
Screen Resolution
1366x768
Hard Drives
Samsung 840 SSD 500GB
1TB USB3 external HD
Cooling
Coolermaster Notepal U3 notebook cooling pad
Internet Speed
3mbps ASDL
Antivirus
ClamWin 0.98.7
Browser
Opera 12.17 x86 (main), Firefox 38 (sec), IE11 (last resort)
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

Computer Manufacturer/Model Number
HP Media Center
OS
Windows 7 32 bit
CPU
AMD 5200+ dual core
Memory
2 GB
Graphics Card(s)
NVidia GeForce 6150SE 128 MB
Monitor(s) Displays
CRT
Screen Resolution
1280x1024
Hard Drives
500 GB Sata internal :

SIIG USB 3.0 docking stations w/WD Caviar Black 6 Gb/s drives
Keyboard
PS/2
Mouse
PS/2 Wheel Mouse
Other Info
SIIG USB 3.0 PCIexpress card.
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

Computer type
Laptop
Computer Manufacturer/Model Number
HP Pavilion dv6-6c10us
OS
x64 (6.3.9600) Win8.1 Pro & soon dual boot x64 (6.1.7601) Win7_SP1 HomePrem
CPU
AMD A6-3420M APU with Radeon(tm) HD Graphics
Motherboard
Hewlett-Packard 1805
Memory
6.00 GB
Graphics Card(s)
AMD Radeon(TM) HD 6520G
Sound Card
(1) AMD High Definition Audio Device (2) IDT High Definiti
Monitor(s) Displays
HP W2072a 20" LCD (1600 x 900) @ 60 Hz
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 60 Hz
Hard Drives
ST640LM0 00 HM641JI SATA Disk Device
Keyboard
Logitech k520 wireless KB
Mouse
Logitech m320 wireless mouse (bundled with KB)
Internet Speed
15/5 | 54 MB Wireless 'n'
Antivirus
Realtime: Defender or Avast | On-demand: Malwarebytes, ESET
Browser
IE 11 on Win8, IE 10 on win 7
Other Info
Media: [Gimp, Audacity, VLC] || Comm: [WEmail 2012, Skype] || Productivity: [OpenOffice,| Textpad] || Utils: [Sysinternals, cCleaner, Speccy, Defraggler]
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

Computer Manufacturer/Model Number
HP Media Center
OS
Windows 7 32 bit
CPU
AMD 5200+ dual core
Memory
2 GB
Graphics Card(s)
NVidia GeForce 6150SE 128 MB
Monitor(s) Displays
CRT
Screen Resolution
1280x1024
Hard Drives
500 GB Sata internal :

SIIG USB 3.0 docking stations w/WD Caviar Black 6 Gb/s drives
Keyboard
PS/2
Mouse
PS/2 Wheel Mouse
Other Info
SIIG USB 3.0 PCIexpress card.

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
HP Pavilion dv6-6c10us
OS
x64 (6.3.9600) Win8.1 Pro & soon dual boot x64 (6.1.7601) Win7_SP1 HomePrem
CPU
AMD A6-3420M APU with Radeon(tm) HD Graphics
Motherboard
Hewlett-Packard 1805
Memory
6.00 GB
Graphics Card(s)
AMD Radeon(TM) HD 6520G
Sound Card
(1) AMD High Definition Audio Device (2) IDT High Definiti
Monitor(s) Displays
HP W2072a 20" LCD (1600 x 900) @ 60 Hz
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 60 Hz
Hard Drives
ST640LM0 00 HM641JI SATA Disk Device
Keyboard
Logitech k520 wireless KB
Mouse
Logitech m320 wireless mouse (bundled with KB)
Internet Speed
15/5 | 54 MB Wireless 'n'
Antivirus
Realtime: Defender or Avast | On-demand: Malwarebytes, ESET
Browser
IE 11 on Win8, IE 10 on win 7
Other Info
Media: [Gimp, Audacity, VLC] || Comm: [WEmail 2012, Skype] || Productivity: [OpenOffice,| Textpad] || Utils: [Sysinternals, cCleaner, Speccy, Defraggler]
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

Computer Manufacturer/Model Number
HP Media Center
OS
Windows 7 32 bit
CPU
AMD 5200+ dual core
Memory
2 GB
Graphics Card(s)
NVidia GeForce 6150SE 128 MB
Monitor(s) Displays
CRT
Screen Resolution
1280x1024
Hard Drives
500 GB Sata internal :

SIIG USB 3.0 docking stations w/WD Caviar Black 6 Gb/s drives
Keyboard
PS/2
Mouse
PS/2 Wheel Mouse
Other Info
SIIG USB 3.0 PCIexpress card.
Back
Top