PDA

View Full Version : %userprofile%



tpeck
Jan 11th, 2010, 08:31 AM
I am sorry, this problem is difficult to describe clearly.

The installer app software I am using (to produce a commercial CD) will not install to %SYSTEMDRIVE%/(my folder)\

It doesn't have the macro to make it possible to always install to the root drive (which is usually C: but could be D: E: etc. on some users' machines).

So I am forced to load the index of my app to the (universal) My Documents folder (instead of to the C:\(my folder)\ where I would like it.

(I am loading the index on the user's hard drive so it doesn't take forever to access the CD).

The reason I would like the folder in the root drive is because it makes it so much easier for various pages on the CD to interact with the index:

I am presently able to write an onclick (in a page on the CD) thus:


onclick="window.open('file:///'+menuletter+':/(my folder)/(myfile)');

(The 'menuletter' variable value is obtained from a cookie... and it works well.)

...but now I am having to use this installer app to give my users an automatic installation.

And I can no longer install to the Root Drive, I must install to something like My Documents. (Trying to install to %ProgramFiles% for example, will not work for me on 64 bit machines - because I cannot code on a page on the CD:


onclick="window.open('file:///%PROGRAMFILES%/(my folder)/(myfile)');

...it will fail on 64-bit machines.)

OK, so my problem is, I am stuck because if I use the installer app's macro to install the index to (my folder in) My Documents, the installer does the job, but the code to use within a page on the CD is thus:


onclick="window.open('file:///%USERPROFILE%/%My%20Documents%/(my folder)/(myfile)');

...and it mysteriously fails! Why?

It goes looking for:
file:///%25USERPROFILE%25/%My%20Documents%/(my folder)/(myfile)

Can anyone tell me where the "25" comes from?

It might work if that doesn't get added.

Thanks.

Philip M
Jan 11th, 2010, 08:57 AM
It goes looking for:

Can anyone tell me where the "25" comes from?



The % symbol is ASCII 25 hex.

Try escaping it. Or try using a regex to delete it.

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

tpeck
Jan 11th, 2010, 09:42 AM
Thanks Philip (you are always so helpful!)... that narrows it down.

My actual code is:


<script>
<!--
function goIndex(){
if (screen.width != 800) {
window.top.navigate('file:///%USERPROFILE%/My%20Documents/1001/menu/menu(1024).html','','resizable=yes,channelmode');
}
else {
window.top.navigate('file:///%USERPROFILE%/My%20Documents/1001/menu/menu(800).html','','resizable=yes,channelmode');
}
}
//-->
</script>

...but escaping the % doesn't seem to do the trick.