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
MasteRG

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

06 Nov 2012   #2
Alejandro85

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
MilesAhead

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
Alejandro85

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
MilesAhead

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 W7.
My System SpecsSystem Spec
07 Nov 2012   #6
Slartybart

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

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
Slartybart

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
MilesAhead

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





Similar help and support threads
Thread Forum
I need a batch file to open a random file within a certain folder/path
I want a batch to select and open a random link file in a folder i have. All the links are music videos I like to listen to, and I kind of want to just have an option for 'surprise me!'. I can change the file names if I have to, and I have a basic batch file ability. I know the simple commands,...
General Discussion
How to run a batch file at logoff & some batch scripting help please
Hiya, I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups. Two questions: 1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd...
Backup and Restore
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
batch file open file for program in the startup folder
I have a computer that is a drone specifically for an outside LED sign. This computer is designed to never shut off and doesn't have any other program on it besides Operating System and the sign software. I need to create a batch file that I can place in the "start-up" folder that will open the...
General Discussion
batch file request
Hi, don't know if anyone has any ideas on this, but here goes - I have a removeable drive with over 100,000 karaoke zip files. Currently, a typical path is "T:\karaoke\soundchoice\100x". That folder may contain 1000's of zip files, and may even be broken down into more folders. I want all the zip...
General Discussion
How to create a batch file that will move files based on the file type
How to create a batch file that will move files based on the file type? My Requirement : I need a batch file to copy all .doc files in all my HardDisk to a removable disk say (Z: drive) . Can anyone make it possible using a batch file?Please...Its urgent...
General Discussion

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 11:23.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App