MSFN Forum: import current path into registry by commandline - MSFN Forum

Jump to content



Unattended CD/DVD Guide Homepage · MSFN Forum Rules

Welcome to the Applications Installs forum. Make sure you read the forum rules before you start posting.

Links/Requests to warez and/or any illegal material (porn, cracks, serials, etc..) will not be tolerated. Discussion of circumventing WGA/activation/timebombs/keygens or any other illegal activity will also not be tolerated.

We try our best to keep this forum clean of illegal content. If you see any illegal activity use the "report" button you find in every post to report the specific post to the moderators. If you ignore any of the rules you will be banned without notice.

Read Forum Rules
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

import current path into registry by commandline Rate Topic: -----

#1 User is offline   QKnet 

  • Newbie
  • Group: Members
  • Posts: 37
  • Joined: 24-September 04

Posted 09 December 2006 - 08:34 AM

I have this registry key
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Collectorz.com\Movie\Databases]
"CurrentDatabase"="D:\\Movie Collectorz\\Data\\khanh.mvc"


Can you tell me the commandline or autosit script to import the key into registry with the "D:\\Movie Collectorz\\Data\\" replaced by the current path of the cmd file.

Thank you very much


#2 User is offline   ajua 

  • Custom Installer Maker
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,260
  • Joined: 16-April 05

Posted 09 December 2006 - 03:03 PM

i dont know exactly but search for DOS system variables.
you can use some as SYSTEMDRIVE USERPROFILE etc...

#3 User is offline   IcemanND 

  • MSFN Junkie
  • Group: Super Moderator
  • Posts: 3,249
  • Joined: 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 09 December 2006 - 03:14 PM

reg add HKCU\Software\Collectorz.com\Movie\Databases /v CurrentDatabase /t REG_SZ /d "%CD%"


Will only have a problem if the current directory is the root directory.

#4 User is offline   Rico.JohnnY 

  • Member
  • PipPip
  • Group: Members
  • Posts: 242
  • Joined: 02-June 04
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 10 December 2006 - 07:12 PM

Cmd
Set CurPath=%~dp0 
Set CurPath=%CurPath:~0,-2%
REG ADD "HKCU\Software\Collectorz.com\Movie\Databases" /v CurrentDatabase /t REG_SZ /d "%CurPath%"


Autoit
RegWrite('HKCU\Software\Collectorz.com\Movie\Databases', 'CurrentDatabase', 'REG_SZ', @ScriptDir)

This post has been edited by Rico.JohnnY: 10 December 2006 - 07:12 PM


#5 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 10 December 2006 - 10:44 PM

@Rico.JohnnY
Your code is wrong, try this to see what I mean!
@ECHO OFF
SET CURPATH=%~DP0
ECHO/%CURPATH%
SET CURPATH=%CURPATH:~0,-2%
ECHO/%CURPATH%
PAUSE
If the location of your running script was C:\Documents and Settings\Rico\Scripting\MyBatch.cmd, your registry input would look like this
C:\Documents and Settings\Rico\Scriptin
I think you may have been looking for %CURPATH:~0,-1%.

I would still be tempted to go with IcemanNDs version which used the current path, and not the location of the script too!
REG ADD HKCU\Software\Collectorz.com\Movie\Databases /V CurrentDatabase /D "%CD%" /F>NUL


#6 User is offline   Rico.JohnnY 

  • Member
  • PipPip
  • Group: Members
  • Posts: 242
  • Joined: 02-June 04
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 11 December 2006 - 06:04 AM

@Yzöwl

Yes..you are right. it's a typo. For the %CD% method, personally i don't like it. Coz you have to use CD command firstly to make sure the working dir is the current dir. Otherwise %CD% should be equal to %userprofile% generally .

#7 User is offline   IcemanND 

  • MSFN Junkie
  • Group: Super Moderator
  • Posts: 3,249
  • Joined: 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 11 December 2006 - 07:26 AM

%CD% gives you the current directory. So if you double click on the CMD file it will be the directory the script resides in. If you open a cmd window and run it from another directory it will give you the path to the directory you are currently in. If you create a shortcut to it then it depends upon the setting in "Start In:" as to what you will get back.

And actually it is still not right. Since he wanted the filename also. And by adding two lines you fix the problem with running it in the root directory.

set backslash=
if not "%cd:~-1%" == "\" set backslash=\
REG ADD HKCU\Software\Collectorz.com\Movie\Databases /V CurrentDatabase /D "%CD%%backslash%khanh.mvc" /F>NUL


note: everything from REG ADD to >NUL should be on one line.

#8 User is offline   QKnet 

  • Newbie
  • Group: Members
  • Posts: 37
  • Joined: 24-September 04

Posted 11 December 2006 - 07:52 AM

View PostIcemanND, on Dec 11 2006, 07:26 AM, said:

%CD% gives you the current directory. So if you double click on the CMD file it will be the directory the script resides in. If you open a cmd window and run it from another directory it will give you the path to the directory you are currently in. If you create a shortcut to it then it depends upon the setting in "Start In:" as to what you will get back.

And actually it is still not right. Since he wanted the filename also. And by adding two lines you fix the problem with running it in the root directory.

set backslash=
if not "%cd:~-1%" == "\" set backslash=\
REG ADD HKCU\Software\Collectorz.com\Movie\Databases /V CurrentDatabase /D "%CD%%backslash%khanh.mvc" /F>NUL


note: everything from REG ADD to >NUL should be on one line.


Thank you so much. I got what I want. Cheers.
:hello:

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy