PDA

View Full Version : Copy.File Destination from registry. Is it possible?


Nivelir
01-26-2008, 11:18 AM
Hi! I'm trying to combine actions Registry.GetValue & File.Copy to automatise installation process. Is it possible?


This button On Click script doesn't work. But I can't understand how to solve this problem :huh


resultINSTL = Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Great Oaks\\DNA Compiler", "Install Location", true);
File.Copy("AutoPlay\\Docs\\dnac.exe", "resultINSTL", true, true, false, true, nil);

Please help me.

RizlaUK
01-26-2008, 02:55 PM
when using a variable in a function like that, do not wrap it in double quotes


Remove the red parts
resultINSTL = Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Great Oaks\\DNA Compiler", "Install Location", true);
File.Copy("AutoPlay\\Docs\\dnac.exe", "resultINSTL", true, true, false, true, nil);

Nivelir
01-27-2008, 03:37 AM
Thank you for your reply. I'll try it. :D

Nivelir
01-27-2008, 04:32 AM
"" near variable was deleted, but it doesn't help.
Here is code:

instl = Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Great Oaks\\DNA Compiler", "Install Location", true);
-- Display the value read from the Registry in a dialog.
instl = Dialog.Message("Registry Data", "The value read from the Registry is "..instl..".");

-- This function works great..

File.Copy("AutoPlay\\Docs\\dnac.exe", instl, true, true, false, true, nil);
--Check to see if an error occurred.
error = Application.GetLastError();

--If an error occurred, display the error message.
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
end

And error occurs: Destination directory does't exist. :huh But directory exist.
I can't understand how to use variable in this function? What is the problem?

AudioSam
01-28-2008, 03:39 AM
instl = Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Great Oaks\\DNA Compiler", "Install Location", true);
-- Display the value read from the Registry in a dialog.
message = Dialog.Message("Registry Data", "The value read from the Registry is "..instl..".");

-- This function works great..
IFT = Folder.DoesExist(instl);
if IFT == true then
File.Copy("AutoPlay\\Docs\\dnac.exe", instl, true, true, false, true, nil);
else
Dialog.Message("Hey", "The Folders not there.", MB_OK, MB_ICONNONE, MB_DEFBUTTON1)
end

RizlaUK
01-28-2008, 07:28 AM
or if the folder dosent exist then create it so install can proceed

instl= Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Great Oaks\\DNA Compiler", "Install Location", true);

instl = Dialog.Message("Registry Data", "The value read from the Registry is "..instl..".");

if not Folder.DoesExist(instl) then
Folder.Create(instl)
end

File.Copy("AutoPlay\\Docs\\dnac.exe", instl.."\\dnac.exe", true, true, false, true, nil);
error = Application.GetLastError();
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
end

AudioSam
01-28-2008, 08:17 AM
or if the folder dosent exist then create it so install can proceed

instl= Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Great Oaks\\DNA Compiler", "Install Location", true);

instl = Dialog.Message("Registry Data", "The value read from the Registry is "..instl..".");

if not Folder.DoesExist(instl) then
Folder.Create(instl)
end

File.Copy("AutoPlay\\Docs\\dnac.exe", instl.."\\dnac.exe", true, true, false, true, nil);
error = Application.GetLastError();
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
end

Hey Rizla,

I think the main problem with this was:

instl = Dialog.Message("Registry Data", "The value read from the Registry is "..instl..".");

Should be...
message = Dialog.Message("Registry Data", "The value read from the Registry is "..instl..".");
or anything besides instl

Do you agree?
AudioSam

AudioSam
01-28-2008, 08:35 AM
instl = Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Great Oaks\\DNA Compiler", "Install Location", true);
-- Display the value read from the Registry in a dialog.
message = Dialog.Message("Registry Data", "The value read from the Registry is "..instl..".");

IFT = Folder.DoesExist(instl);
if IFT == true then
File.Copy("AutoPlay\\Docs\\dnac.exe", instl, true, true, false, true, nil);
else
FLoc = (YOUR FOLDER LOCATION HERE)----<<<<<<<<<<<<<<<<<<<<Change This
Folder.Create(FLoc)
File.Copy("AutoPlay\\Docs\\dnac.exe", FLoc, true, true, false, true, nil);
end


This would work..
without instl in the registry there would be no reference to the folder.
So Nivelir would have to determine where the folder would be...

RizlaUK
01-28-2008, 01:05 PM
I think the main problem with this was:

omg, how did i not even see that :eek: lol

instl = Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Great Oaks\\DNA Compiler", "Install Location", true);
-- Display the value read from the Registry in a dialog.
message = Dialog.Message("Registry Data", "The value read from the Registry is "..instl..".");

IFT = Folder.DoesExist(instl);
if IFT == true then
File.Copy("AutoPlay\\Docs\\dnac.exe", instl, true, true, false, true, nil);
else
FLoc = (YOUR FOLDER LOCATION HERE)----<<<<<<<<<<<<<<<<<<<<Change This
Folder.Create(FLoc)
File.Copy("AutoPlay\\Docs\\dnac.exe", FLoc, true, true, false, true, nil);
end

i agree that seems the best way, nice call :yes

AudioSam
01-28-2008, 11:31 PM
Thanks Riz,

I had one of the Best help me when I asked.
That was you my friend. You have helped so
many that have asked, always having the right answers.
I had read Nivelir's "It doesn't help" post and
thought I would throw something in.

Ok,,,enough of the mushy stuffff :D
AudioSam

Nivelir
01-29-2008, 03:44 PM
Thanks a lot fellows. I'll try it. It's realy nice that you helping me.

ps: sorry for my poor english

littlepharaoh5
02-03-2008, 02:45 PM
hi

I think the problem in instl its content in reg must b like

c:\folder\
i did it befor and it works

how u input instl value in the reg??(input or some thing els)
is the folder created ??
if not u must add creat folder using instl before the copy

Nivelir
02-04-2008, 04:03 AM
hi

I think the problem in instl its content in reg must b like

c:\folder\
i did it befor and it works

how u input instl value in the reg??(input or some thing els)
is the folder created ??
if not u must add creat folder using instl before the copy


Script posted by AudioSam works great. The problem was in rewriting instl variable:

instl= Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Great Oaks\\DNA Compiler", "Install Location", true);

instl = Dialog.Message("Registry Data", "The value read from the Registry is "..instl..".");

It was my mistake.
Registry key is already in system regystry, my target was to read it from there and use like an install path.
And yes, folder is already created, but its path may vary, thats why I need regystry key which has current path.