Jump to content

[HELP] How to auto insert current path into a reg file


ns870152

Recommended Posts

Example: I have a file *.reg with content:

[HKEY_LOCAL_MACHINE\SOFTWARE\Program name]

"Path"="D:\\Program name\\"

If I move "Program name" to E:

I must edit:

[HKEY_LOCAL_MACHINE\SOFTWARE\Program name]

"Path"="E:\\Program name\\"

How to auto insert the correct/current path without changing the reg file ?

Thank you in advance

Edited by ns870152
Link to comment
Share on other sites


  • Replies 14
  • Views 1.7k
  • Created
  • Last Reply

Top Posters In This Topic

  • ns870152

    6

  • MasterZeus

    5

  • Dodel

    3

  • Kalju

    1

Top Posters In This Topic

Could you not make it portable, using something like thinstall app or similar, (That way it's always looking for it's *root*\\path.)

Link to comment
Share on other sites


Could you not make it portable, using something like thinstall app or similar, (That way it's always looking for it's *root*\\path.)

Thank you

Some softwares can't be made portables by Thinapps, Cameyo, SpoonStudio...

for PES game, I can use the path: "installdir"=".\\", I can copy it everywhere without problem

in a bat file, I can use %~dp0 to get current path but in a reg file, I don't know...

Link to comment
Share on other sites


Could you not make it portable, using something like thinstall app or similar, (That way it's always looking for it's *root*\\path.)

Thank you

Some softwares can't be made portables by Thinapps, Cameyo, SpoonStudio...

for PES game, I can use the path: "installdir"=".\\", I can copy it everywhere without problem

in a bat file, I can use %~dp0 to get current path but in a reg file, I don't know...

Sorry for the quick, basic replies (I'm posting from work), without fully understanding what you're trying to do, I can only partially guess.

Anyhow you can use :-

[%SystemRoot]in a reg key for the local install path. (If I'm going along the right lines.)

Regards

Dodel.

Edited by Dodel
Link to comment
Share on other sites


Example: To open (association) a DOC file with Word 2003 portable, I use a bat file (in Office 2003 folder) with content:

assoc .doc=Word

ftype Word="%~dp0Microsoft Office Word 2003.exe" "%%1"

I can copy Office 2003 folder to everywhere, the bat file is still right working

because %~dp0 is the current path where the bat is in

I want to do the same with a Reg file

Sorry for my ugly explaination

Edited by ns870152
Link to comment
Share on other sites


Here is Your Solution :)

@echo offecho [HKEY_LOCAL_MACHINE\SOFTWARE\Program name]  2>&1 > myReg.regset CUR_DIR=%~dp0set NEW_PATH=%CUR_DIR:\=\\%echo."Path"="%NEW_PATH%" 2>&1 >> myReg.reg
Edited by MasterZeus
Link to comment
Share on other sites


Here is Your Solution :)

Thank you, but the code replace all keys of the reg

Here exact the REG I want to do:

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Labcenter Electronics]

[HKEY_LOCAL_MACHINE\SOFTWARE\Labcenter Electronics\Licences 1.1]

[HKEY_LOCAL_MACHINE\SOFTWARE\Labcenter Electronics\Licences 1.1\Professional]

(...)

[HKEY_LOCAL_MACHINE\SOFTWARE\Labcenter Electronics\Proteus 8 Professional]

"Path"="D:\\Electronics\\Proteus8\\"

"Version"="8.0.15417.0"

"ProgramData"="D:\\Electronics\\Proteus8\\Data\\"

"LicenceFamily"="Professional"

"Product"="Proteus Professional"

[HKEY_LOCAL_MACHINE\SOFTWARE\Labcenter Electronics\Proteus 8 Professional\Update Manager]

"UpdateSchedule"=dword:00000007

[HKEY_LOCAL_MACHINE\SOFTWARE\Labcenter Electronics\Proteus Professional]

[HKEY_LOCAL_MACHINE\SOFTWARE\Labcenter Electronics\Proteus Professional\7]

"UpdateFrequency"=dword:00000003

D:\\Electronics\\Proteus8\\ is the path auto replaced (as a variable) when I (or my friends who shared) don't copy to right to this location

Edited by ns870152
Link to comment
Share on other sites


Solution 1:
1) Add All Registry Entry From 1st reg File (applicationReg.reg <-- [Your Current reg File As it is])
2)Updated Path From 2nd reg File (newPath.reg)
@echo offSETLOCAL ENABLEDELAYEDEXPANSIONreg import applicationReg.regecho REGEDIT4 2>&1 > newPath.regecho. 2>&1 >> newPath.regecho [HKEY_LOCAL_MACHINE\SOFTWARE\Labcenter Electronics\Proteus 8 Professional] 2>&1 >> newPath.regset CUR_DIR=%~dp0set NEW_PATH=%CUR_DIR:\=\\%echo."Path"="%NEW_PATH%" 2>&1 >> newPath.regecho."ProgramData"="%NEW_PATH%Data\\" 2>&1 >> newPath.regreg import newPath.reg
Edited by MasterZeus
Link to comment
Share on other sites


Solution 2:
1) Add All Registry Entry From reg File (applicationReg.reg <-- [Your Current reg File As it is])
2)Updated Path Directly To The Registry
@echo offSETLOCAL ENABLEDELAYEDEXPANSIONreg import applicationReg.regset CUR_DIR=%~dp0REG ADD "HKLM\Software\Labcenter Electronics\Proteus 8 Professional"   /f /v Path /t REG_SZ /d "%CUR_DIR%REG ADD "HKLM\Software\Labcenter Electronics\Proteus 8 Professional" /f /v ProgramData /t REG_SZ /d "%CUR_DIR%Data\
Edited by MasterZeus
Link to comment
Share on other sites


Solution 3:
Directly Update Path to the reg File (applicationReg.reg <-- [Your Current reg File As it is])
@echo offSETLOCAL ENABLEDELAYEDEXPANSIONset cur_path=%~dp0set cur_path=%cur_path:\=\\%FOR /F "tokens=1,* delims==" %%A in ('type applicationReg.reg') do (set line=%%Bif defined line ( if %%A == "Path" (  echo %%A="%cur_path%" 2>&1 >> newPath.reg )else if %%A == "ProgramData" (echo %%A="%cur_path%Data\\" 2>&1 >> newPath.reg ) else echo.%%A=%%B 2>&1 >> newPath.reg) else (echo.%%A 2>&1 >> newPath.reg      echo. 2>&1 >> newPath.reg ) )del /F applicationReg.regren newPath.reg applicationReg.reg
Edited by MasterZeus
Link to comment
Share on other sites


@MasterZeus: Thank you very much

Is there any solution for only reg file without using bat file ?

Some games/softwares are packed by WinRAR allow changing the install path and importing correct path to registry. How does it do ?

Edited by ns870152
Link to comment
Share on other sites


@MasterZeus: Thank you very much

Is there any solution for only reg file without using bat file ?

Some games/softwares are packed by WinRAR allow changing the install path and importing correct path to registry. How does it do ?

Don't Know About But i Think They Run Some POST Installation Script To Update Path in Registry.

Link to comment
Share on other sites


Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...