QKnet Posted December 9, 2006 Share Posted December 9, 2006 I have this registry keyWindows 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 Link to comment Share on other sites More sharing options...
ajua Posted December 9, 2006 Share Posted December 9, 2006 i dont know exactly but search for DOS system variables.you can use some as SYSTEMDRIVE USERPROFILE etc... Link to comment Share on other sites More sharing options...
IcemanND Posted December 9, 2006 Share Posted December 9, 2006 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. Link to comment Share on other sites More sharing options...
Rico.JohnnY Posted December 11, 2006 Share Posted December 11, 2006 (edited) Cmd Set CurPath=%~dp0 Set CurPath=%CurPath:~0,-2%REG ADD "HKCU\Software\Collectorz.com\Movie\Databases" /v CurrentDatabase /t REG_SZ /d "%CurPath%"AutoitRegWrite('HKCU\Software\Collectorz.com\Movie\Databases', 'CurrentDatabase', 'REG_SZ', @ScriptDir) Edited December 11, 2006 by Rico.JohnnY Link to comment Share on other sites More sharing options...
Yzöwl Posted December 11, 2006 Share Posted December 11, 2006 @Rico.JohnnYYour code is wrong, try this to see what I mean!@ECHO OFFSET CURPATH=%~DP0ECHO/%CURPATH%SET CURPATH=%CURPATH:~0,-2%ECHO/%CURPATH%PAUSEIf the location of your running script was C:\Documents and Settings\Rico\Scripting\MyBatch.cmd, your registry input would look like thisC:\Documents and Settings\Rico\ScriptinI 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 Link to comment Share on other sites More sharing options...
Rico.JohnnY Posted December 11, 2006 Share Posted December 11, 2006 @YzöwlYes..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 . Link to comment Share on other sites More sharing options...
IcemanND Posted December 11, 2006 Share Posted December 11, 2006 %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>NULnote: everything from REG ADD to >NUL should be on one line. Link to comment Share on other sites More sharing options...
QKnet Posted December 11, 2006 Author Share Posted December 11, 2006 %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>NULnote: everything from REG ADD to >NUL should be on one line.Thank you so much. I got what I want. Cheers. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now