Page 1 of 1

Renaming a directory

Posted: Thu Jul 13, 2006 4:41 am
by Tinus
Hi Michael,

I need to rename a directory before the windows installer uninstalls a previous version.
All I found was Copy/Move Local Files - but this is based on MSI.
Is there an easy way to accomplish this?

Posted: Thu Jul 13, 2006 7:14 am
by crustyzz
Personally I use a Dll.
:?

Posted: Thu Jul 13, 2006 7:40 am
by MichaelNesmith
There's a very easy way. Use the MoveFile API with Call DLL Function. No need to author a custom DLL or plug-in for this!

Code: Select all

~InstallAware Clipboard Data~
~Call DLL Function~
~{377AD747-17BC-42DE-9AE6-EB7B8A175777}~
~kernel32.dll,MoveFileA,bool,,"pointer to string",c:\\temp,"pointer to string",c:\\temp2,$~
~mIDEFunc.dll\\mEXEFunc.dll~


This renames c:\\temp to c:\\temp2.

Posted: Thu Jul 13, 2006 7:52 am
by Tinus
Michael,

thank you.

Posted: Thu Jul 13, 2006 11:00 am
by Tinus
This one drives me crazy. Running in the debugger is ok. Running standalone I get an
"unable to load plug-in library. Please rebuild project...".

A few lines above I already use the "call DLL plug-in."
What I'm doing wrong?

Posted: Thu Jul 13, 2006 3:16 pm
by Tinus
After hours of try and error I finally deleted the command and reentered it again manually. And now it works!

The difference is - the GUID!

Code: Select all

~InstallAware Clipboard Data~
~Call DLL Function~
~{974D685E-3C60-4F2A-892E-3035C85DC000}~
~kernel32.dll,MoveFileA,bool,RENAME,"pointer to string",$OLDDBDIR$,"pointer to string",$OLDDBDIR$.1,$~
~mIDEFunc.dll\\mEXEFunc.dll~

Posted: Thu Jul 13, 2006 7:53 pm
by MichaelNesmith
Were you using the same GUID in both commands?

Posted: Fri Jul 14, 2006 12:59 am
by Tinus
No,

I simply cut'n pasted your sample into my script. Then I changed the two directory names.
It was running in the debugger but always failed at runtime.

Then after hours I gave up and deleted the command and reentered it manually again.
It is exactly the same as before but now it's working.

Finally I copied my command to the clipboard and compared my working version with yours.
And the only difference is the GUID.

I don't understand what is wrong here. But I remember that I had a similar problem some days ago.
A copied If command behaved exactly the other way around. I also deleted this and entered it again and it was working.

Posted: Fri Jul 14, 2006 7:10 am
by MichaelNesmith
Oh, I think the problem is because you pasted the same copied text twice - so both pastes ended up with the same GUID.

I'll be sure to file this as an issue - GUIDs have to be monitored on paste to make sure there aren't any duplicates.

Posted: Fri Jul 14, 2006 7:29 am
by MichaelNesmith
Actually, I was wrong - the IDE is already checking for that, apparently. I really don't know why that's happened on your end, sorry.

Posted: Thu Sep 13, 2007 2:21 pm
by sdeschenes
I just tried using the sample code that MichaelNesmith posted and I get the same error: "unable to load plug-in library. Please rebuild project...". It works when I run it through the debugger. Any more thoughts on this?

Posted: Fri Sep 14, 2007 10:54 am
by sdeschenes
I did what Tinus had mentioned earlier, manually entered the command, and it worked. It is weird that the function would fail if the code was copied from another source and pasted into the script.