Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Regedit help


  • Please log in to reply

#1
stettybet0

stettybet0

    Trusted Tech

  • Technician
  • 2,579 posts
Hi, I'm trying to make a regedit (.reg) file for Windows XP. I need to find out how to use the current directory. Here's what I have. It doesn't work and the registry entry never appears.

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce]
"Install2"="%CD%\Install2.bat"

The Install2.bat is part of the installation procedure of a program I made. It needs to be run after Install.bat reboots the computer. It is located in C:\Program Files\XTA\. However, when other people download this program, they may save it in a different directory, so I need to find current directory. But even when I try:

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce]
"Install2"="C:\Program Files\XTA\Install2.bat"

it doesn't work. The registry entry never appears.

When I try:

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce]
"Install2"="Install2.bat"

the registry entry appears, but it doesn't work, for obvious reasons.

Any help would be greatly appreciated.

Thanks,
stettybet0

EDIT: I need the registry to know the current directory from which Install.bat was launched (and therefore Install2.bat is located). I'm not sure if something like %CD% would even work because the computer has been restarted.

Edited by stettybet0, 06 April 2007 - 05:34 PM.

  • 0

Advertisements


#2
stettybet0

stettybet0

    Trusted Tech

  • Topic Starter
  • Technician
  • 2,579 posts
Alright, I got something which kind of works, but my edit above was right... %CD% either isn't a valid command for regedit, or %CD% isn't set to the correct directory... Help?

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce]
"Install2"="%CD%\\Install2.bat"

Just needed to put another \ it turns out. :whistling:

EDIT: The following works:

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce]
"Install2"="C:\\Program Files\\XTA\\Install2.bat"

As I mentioned before, if another person downloaded my program into a different directory... then this would not work. If only I could make it remember the directory in which the person downloaded the files to... I would be set. I'm so close!

Edited by stettybet0, 06 April 2007 - 05:48 PM.

  • 0

#3
stettybet0

stettybet0

    Trusted Tech

  • Topic Starter
  • Technician
  • 2,579 posts
I figured it out by myself.
  • 0

#4
Vaillant

Vaillant

    Member

  • Member
  • PipPipPip
  • 495 posts
The simplest way to refer to the same directory is to use the .

to specify current directory, you simply have to put

.\file.bat

I'm guessing thats what you found... if not, then this is the prefferred way of doing so. :whistling:
  • 0

#5
stettybet0

stettybet0

    Trusted Tech

  • Topic Starter
  • Technician
  • 2,579 posts
That didn't work due to the system restarting and automatically being in C:\Documents and Settings\Owner... I did a lot of things, the exact script is long and on another computer, but I just made the batch copy all files to C:\Program Files\XTA from where ever they downloaded them to. Then install2.bat ran in that folder no matter what.
  • 0

#6
Vaillant

Vaillant

    Member

  • Member
  • PipPipPip
  • 495 posts
Ah, that's a pretty good way of doing it. Nice. :whistling:
  • 0

#7
stettybet0

stettybet0

    Trusted Tech

  • Topic Starter
  • Technician
  • 2,579 posts
Thanks... the exact code (minus echoing as it is not important for the function of the files) for install.bat and install2.bat for anyone who needs it: (obviously filenames need to be modified... also the CHANGE.COM file is required)

rem Install.bat
@echo off
mkdir "C:\Program Files\XTA"
copy .\Setup.exe "C:\Program Files\XTA\"
echo REGEDIT4>>.\Install2.reg
echo.>>.\Install2.reg
echo [HKEY_CURRENT_USER+Software+Microsoft+Windows+CurrentVersion+RunOnce]>>.\Install2.reg
echo "Install2"="%CD%\Install2.bat">>.\Install2.reg
change .\Install2.reg "\" "\\"
change .\Install2.reg "+" "\"
regedit /s .\Install2.reg
del .\Install2.reg
shutdown -r -t 0
exit

rem Install2.bat
@echo off
cd C:\Program Files\XTA
start "Setup" "%CD%\Setup.exe"
exit

Edited by stettybet0, 07 April 2007 - 08:01 PM.

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP