Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


Sign in to follow this  
Kullenen_Ask

Autorun batch file systax

Recommended Posts

I will have a "X:\Program Files\RegImport\" folder. In this folder there will be files "1.reg", "2.reg", "3.reg" etc.

I want to run a Autorun.cmd and call it at boot and i want it to register the files in that folder. Something like below but i do not know the right systax.

If the path values can be like %programfiles% it can be more better.

@echo offset "Folder=X:\Program Files\Regimport"FOR /f "tokens=*" %%A IN ('dir X:\Program Files\Regimport) DO regsvr32 %%Aexit
Edited by Kullenen_Ask

Share this post


Link to post
Share on other sites

Which OS/PE?

I mean you could use forfiles:

http://ss64.com/nt/forfiles.html

In more traditional batch, it would be more something like:

@echo off
set files="X:\Program Files\Regimport\*.reg"
FOR /f "tokens=*" %%A IN ('dir /B %files%') DO ECHO regsvr32 %%A

(I changed it in such a way that only *.reg files will be listed)

But there is something "wrong". :ph34r:

Regsvr32 is to register .dll's in the registry, NOT to merge .reg fies! :w00t:

http://ss64.com/nt/regsvr32.html

maybe you meant either of :

http://ss64.com/nt/reg.html

http://ss64.com/nt/regedit.html

jaclaz

Share this post


Link to post
Share on other sites

Sorry there will be reg files register only with reg.exe. I wrote wrong. I will put in there forexample "7zip.reg,winrar.reg,winmount.reg...etc". I want them to be seperate because i can frequenty add or remove programs and i want all programs reg additions to be seperate. I will use in winpe. Will try your code if it works.

Share this post


Link to post
Share on other sites

I think what you are looking for is:

@FOR %%A IN ("X:\Program Files\Regimport\*.reg") DO @REGEDIT /S "%%~A"

Share this post


Link to post
Share on other sites

Yzöwl your solution looks more short. Can i use it like this or i need to try and learn?

@FOR %%A IN ("%ProgramFiles%\RegImport\*.reg") DO @REGEDIT /S "%%~A"

Share this post


Link to post
Share on other sites

You can use it like that if your reg files are actually part of the running Operating System otherwise the %PROGRAMFILES% Environment Variable will not be correct.

Share this post


Link to post
Share on other sites

Batch file works ok. I am tested. Also with %PROGRAMFILES% Environment Variable

@FOR %%A IN ("%ProgramFiles%\RegImport\*.reg") DO @REGEDIT /S "%%~A"
Edited by Kullenen_Ask

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...