mIRC Homepage
Posted By: pouncer file path handling with vista - 27/11/07 11:29 PM
i've heard that on vista, the file path handling is different then on other os's? is this true?

can i still use $scriptdirfolder and $mircdiranotherfolder as usual?
Posted By: Jyang Re: file path handling with vista - 28/11/07 12:47 AM
This was only a problem in mIRC 6.3. In 6.31, mIRC installs to a Roaming folder.
Posted By: pouncer Re: file path handling with vista - 28/11/07 01:55 PM
Sorry, what is a roaming folder?
Posted By: Horstl Re: file path handling with vista - 28/11/07 03:12 PM
"roaming"
In addition, start out a search for vista and $mircdir - you'll find plenty of posts about the "new" $mircdir behaviour.
Regards smile
Posted By: pouncer Re: file path handling with vista - 28/11/07 03:21 PM
thanks!

so it was only a problem on 6.3? so the rest of the versions are fine?

so on 6.3, $mircdir will point to the applications folder?
Posted By: Riamus2 Re: file path handling with vista - 28/11/07 08:42 PM
All versions before 6.31 have this "problem". And it's not really a problem anyhow, depending on how you install. Of course, for the casual user who just installs normally, it acts like a problem, which is why it was changed.

In any case, you can avoid it with older versions of mIRC by installing mIRC to use the install folder rather than the Virtual Store folder by placing a mIRC.ini file into the install folder. Note that in Vista, you will want to set full access to that folder for your login to prevent issues with writing to the folder for logs/downloads/etc. As long as you give full access to the folder, it works the same in Vista as in pre-Vista.

Of course, you could also install mIRC to a location where you already have full access, such as a folder on the desktop, and you'll get the same results.
Posted By: pouncer Re: file path handling with vista - 29/11/07 10:50 PM
Sorry, my question was about how this affects mirc scripting, nothing to do with me installing mirc on vista or whatnot.

i don't use vista, my question is about making scripts compatible on vista as well as xp

so i guess i'll just put a version check to make sure the mirc version != 6.3
Posted By: RusselB Re: file path handling with vista - 29/11/07 11:12 PM
The easiest way to ensure this, is to go through your scripts and replace $mircdir with $scriptdir

As to the version check, not a bad idea, but I'd recommend using $version < 6.3 rather than $version != 6.3

I believe you're knowledgeable enough to see why.
Posted By: starbucks_mafia Re: file path handling with vista - 29/11/07 11:48 PM
You definitely should not just replace $mircdir with $scriptdir. It's a really scrappy method and forces the user to install the script files somewhere that can be written to by all users which is as good a reason as any to not install that script.
Posted By: RusselB Re: file path handling with vista - 30/11/07 01:56 AM
then how about an alternative suggestion?
Posted By: starbucks_mafia Re: file path handling with vista - 30/11/07 02:01 AM
The post I linked explained it.
Posted By: RusselB Re: file path handling with vista - 30/11/07 06:00 AM
Sorry, for some reason it didn't show as a link when I pointed at it.
Posted By: pouncer Re: file path handling with vista - 30/11/07 03:18 PM
Hi starbuck, thanks for linking to that thread. I am still very very confused, can someone kindly please help me further?

so the issue is with mirc 6.3 on vista.

say i have a folder in my script directory called 'scripts' and in this folder i have script1.mrc

if i use $mircdir in script1.mrc will it NOT return the script directory folder? but it WILL return the scriptdirectory/scripts folder?? right? on my xp, im using $mircdir in all my scripts, and these scripts are in a subfolder ... so this would be a problem on vista?
Posted By: Riamus2 Re: file path handling with vista - 30/11/07 10:38 PM
$mircdir in Vista will point to wherever mIRC.ini is located, wheter that is your mIRC folder or the one in Appdata depends on the user's installation. $scriptdir will point to wherever the script is installed.

If you use $mircdir\scriptname\whatever, and someone puts the script into the mIRC installation folder instead of in the Appdata location, then it will point to the wrong location. I think people need to consider installing scripts into the Appdata location in the future, but that doesn't help for everyone who chooses not to. $scriptdir should point to the correct location no matter how people have things set up in Vista... just remember that you cannot write to the mIRC install folder without changing settings, so if you are writing settings, you will not want to use $scriptdir.

A good option is to use $scriptdir for locating the actual script, and then saving all settings into $mircdir\scriptname\ or whatever. Using a combination of both should allow things to work regardless of how people have things set up... your settings will just not be in your mIRC install folder.
Posted By: starbucks_mafia Re: file path handling with vista - 30/11/07 11:21 PM
OK, I'm going to try and thoroughly explain what's going on. Hopefully this will make some sense:
  • There's nothing special about how $mircdir and $scriptdir work on Vista. They behave the same as they do on any other version of Windows.

  • The actual behaviour of $mircdir and $scriptdir has not changed at all. To clarify what those behaviours are:
    - $mircdir is the 'root' directory. This is the place where any relative filenames will start from, and it is the place that mIRC will look for the mirc.ini settings file (unless that's been overridden using mIRC's -i command-line switch).
    - $scriptdir always points to the directory containing the currently executing script.

  • What has changed from v6.3 onwards is the default locations that mIRC uses for storing settings. I cannot stress enough that this doesn't affect how $mircdir works and that any script that correctly uses $mircdir prior to 6.3 will continue to work correctly after 6.3. The problem is that prior to 6.3 a lot of people apparently misunderstood what $mircdir did, and thought that it always returned the directory containing mirc.exe (because versions prior to 6.3 used to store settings there by default).


From all this we can figure out a few things:
  • $mircdir can always be assumed to be a writeable location for the given user, $scriptdir cannot - ie. a script could be installed by an admin but used by a non-admin who has read-only access to the script's directory.

  • $mircdir will always return a directory so that your script behaves appropriately for how the user has set up mIRC. What I mean is that whether the user has chosen to use mIRC in a multi-user way (the default from 6.3 onwards) or whether they've chosen to use mIRC so that all users use the same settings (the pre-6.3 way) then by using $mircdir for storing your script's settings it will always work how the user wants it.


So in conclusion:

Anything that could be written by the user (ie. settings, savegames, downloads, whatever) should use $mircdir. Anything that will not be changed by the user (ie. script resources like icons or default sounds etc.) should use $scriptdir (which should be fairly logical since they'll presumably be installed there with the script files).
Posted By: Horstl Re: file path handling with vista - 01/12/07 12:17 AM

/me votes this post becomes a sticky, as this issue is asked time and again
Posted By: Riamus2 Re: file path handling with vista - 01/12/07 01:40 AM
Much better explanation than mine. smile
© mIRC Discussion Forums