VideoHelp Forum




+ Reply to Thread
Results 1 to 10 of 10
  1. Unfortunately, I am an idiot.
    I spend a lot of time figuring out how to make things work, without fully understanding why they work in the first place, and then I change to a new computer and things stop working...

    For a while I have used AvisynthRepository (https://forum.doom9.org/showthread.php?t=172124) to work with my .avs files.
    I load .avs scripts into VirtualDub.

    At some point, I used the AvisynthRepository "setavs.bat/cmd" configurator to select opening AVS files using "x64" AVISynth. It worked fine for AVS files that didn't have any 32-bit plugins that I use in my other scripts.

    Then I created an AVS files that relied on some 32-bit plugins, and therefore I used setavs to try changing back to x32 AVISYNTH.
    But the .avs script wouldn't load in VDub. Maybe my stupid new Windows 11 install on a new machine was somehow blocking setavs's attempts to write some necessary file to some folder (I have had this happen with other files/folders) - I don't know. As I said, I am an idiot.

    After this attempt, the system seemed to be going to plugins64 folder, still. The reason I know it is because if I copied certain files that my script used from the regular (32 bit) "plugins" folder to "plugins64" the error messages would stop complaining about not finding them, but then throw further error messages.

    In frustration, I tried to UNINSTALL x64 AVISYNTH from setavs.

    It seemed to achieve that objective, but now if I try to open AVS files in VirtualDub I just get:
    AVI Import Filter error: (Unknown) (80040154)

    So, something is fundamentally broken and I don't know what DLL isn't registered wherever/however, because as I mentioned, I suffer from being an idiot in these matters.

    Is there some clear strategy I can use to debug this problem so I can load my many AVS scripts?

    What I'd really love to know is: when I tell VirtuaDub to open my AVS file, what actually happens?
    What DLL/registry setting is needed by VirtualDub to successfully process my script and actually then start loading any avisynth .dlls/functions used by my script - and how exactly does my system know where to go? 'PATH' Environment variable?

    Thanks for any help.
    Quote Quote  
  2. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    You shouldn't be mixing up 32 and 64 dll's, that's potentially creating a mess
    Does the script open in AvsPmod?
    What about a simple script such as:
    Code:
    version()
    Quote Quote  
  3. Originally Posted by davexnet View Post
    You shouldn't be mixing up 32 and 64 dll's, that's potentially creating a mess
    Does the script open in AvsPmod?
    What about a simple script such as:
    Code:
    version()
    To your first point, I do not mix 32 and 64 bit dlls in one AVS script.
    Yes, most of AVISynth's plugins are 32-bit.
    Occasionally, however, my simpler scripts could run much faster if I used the x64 AVISynth
    I previously used AvisynthRepository just fine on my old Win 8.1 machine, switching back and forth as necessary.

    To your suggestion: I have downloaded both 32 and 64 bit versions of AvsPMod.
    (And I already see a potential problem with this Win11 system because just copying the 32-bit folder for this app to one of my subfolders was really difficult. Win11 would get to the .exe file and suddenly I would get the "Permission Denied" dialog. Then when I finally managed to overcome that problem, my wonderful Antivirus blocked something, causing me to have to go in and add "exceptions" to prevent it from blocking AvsPMod. Anyway, that's a different topic but could possibly explain why I am having trouble with using AvisynthRepository on this machine.)

    So, I dropped the version() avs script onto AvsPMod.exe. It opened the program with the text of this script.
    I pressed the "Play" button and I see this:
    AviSynth+ 3.7.0. (r3382, 3.7, i386)
    (c) 2000-2015 Ben Rudiak-Gould, et al.
    http://avisynth.nl
    (c) 2013-2021 AviSynth+ Project

    Incidentally, I thought to try opening again my original AVS (in VirtualDub) and, lo and behold, I no longer got that 80040154 error (did me doing something in my Antivirus settings fix a problem? I don't know) and now I am getting a different error from VirtualDub:

    Avisynth open failure:
    Script error: There is no function named 'FFMpegSource2'.
    (Of course, the same error is reported by your AvsPMod).

    So, at least some improvement - but I am still an idiot. As far as I understand, FFMpegSource2 is located in ffms2.dll. I happen to have these dlls (one x64 and one x86) in D:\programs-non-setup\AvisynthRepository\plugins64 D:\programs-non-setup\AvisynthRepository\plugins respectively.

    In my registry, I see
    [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Avisynth]
    @="D:\\programs-non-setup\\AvisynthRepository\\AVSPLUS370_x86"
    "PluginDir2_5"="D:\\programs-non-setup\\AvisynthRepository\\AVSPLUS370_x86\\plugins "
    "PluginDir+"="D:\\programs-non-setup\\AvisynthRepository\\AVSPLUS370_x86\\plugins "


    Of course, the trouble is that I have the required dll in
    D:\\programs-non-setup\\AvisynthRepository\\plugins"
    Not
    D:\\programs-non-setup\\AvisynthRepository\\AVSPLUS370_x86\\plugins "

    But ok, let's just say I roll with it and copy ffms2.dll to that folder...
    Nothing, still the same error.
    Then, before posting this, I figured, let me see what would happen if I copied the x64 ffms2.dll to "D:\\programs-non-setup\\AvisynthRepository\\AVSPLUS370_x64\\plugins "
    and you know what, doing this actually somehow solved its problem of not finding FFMpegSource2.

    But there are other functions I use and they all reside here:
    It now loads fine, but I have many other functions that are called in my original AVS script that all reside here:
    D:\\programs-non-setup\\AvisynthRepository\\plugins"

    What exactly happens when I try to open my AVS script with VirtualDub (or AvsPMod)?
    Where does the system go to figure out in which folder to look for the necessary plugin dlls or .avsi files used by my script?
    Quote Quote  
  4. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Regarding what I said about mixing up the 32 and 64 bit dll's - what I really meant was them being placed into the wrong plugins folder
    (32-bit dll's put into plugins64 and vice-versa)

    You can load dll's explicity in your script by using
    Loadplugin("c:\path\your_plugin.dll")

    Otherwise:
    If you open a script with a 64 bit version of the host program (AVSPmod, Vdub,etc.) the search for plugins
    will be in the plugins folder(s) as determined by the following key:
    HKEY_LOCAL_MACHINE\SOFTWARE\AviSynth
    and the folder(s) should only contain plugins that are 64 bit versions

    Likewise for a 32 bit host program it searches in
    HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\AviSynth, where the folder(s) should contain 32 bit versions
    of the plugins

    The best way to run AVSPmod and similar portable apps is to create a folder on your desktop and put it in there.
    Antoher place to put them is in C:\Users\your_user\portable_apps\ (with a shortcut on your desktop)
    Then you don't have issues with permissions. Third party A/V and probably Windows Defender, have a "reputation" mode
    and if a file has not been "seen" too often in the wild, it hits you with a warning.

    As a side note,
    The script itself *can* be built using a 32 bit and a 64 bit section by using mp_pipleline. I used it myself once when the whole script was designed
    for 64 bits, but there was one 32 bit plugin I needed the functionality of. IT's only really used for this kind of special case
    Last edited by davexnet; 5th Apr 2024 at 19:49.
    Quote Quote  
  5. I agree that, given that they have the exact same names, it's very easy to mix up 32 and 64 bit plugins. I wish there was a way to tell from properties, or something. One way I can tell if I remember their different file sizes.

    To your point, yes, I used to do Loadplugin in my scripts many years ago, and then I somehow figured out how to setup my system so that running .avs files automatically found the needed plugins in the whatever plugins folder where I kept them. But, as you can see, I have completely forgotten how I set it up to work like that.

    So, it seems you are telling me that if I try to open my AVS script with the 64 bit version of VirtualDub, the system is going to look for a folder with the x64 AVISynth plugins, whereas if I use the 32 bit version of VirtualDub, then it will look for the x86 folder?
    But that's not the case, because the VirtualDub program I am trying to use is, in fact the x86 version. (I just tested to make sure by dropping AVS directly onto it and the nearby VirtualDub2_64.exe.

    In fact, looking at the registry, I don't even have the HKEY_LOCAL_MACHINE\SOFTWARE\AviSynth key.
    Just HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\AviSynth.
    And in this key, it's, in any case, only the x86 folders that are listed, which I mentioned earlier. No keys with x64 and yet that's what seems to be involved.

    I have really tested this. As soon as I remove the ffms2.dll from folder D:\programs-non-setup\AvisynthRepository\AVSPLUS370_x64\plugins, I instantly get There is no function named 'FFMpegSource2' error. I put it back in, the error disappears (but other errors that are all to do with other 32 bit plugins missing).

    You mention the "best place" for keeping programs: I have used D:\programs-non-setup\ folder for storing things like VirtualDub, AviSynthRepository and everything else that you can copy to your machine without needing to run the typical "Setup". This way has been working just fine for me since the old days of Windows XP 20 years ago.

    Now I am having trouble.

    I need to understand what is happening on my system that's causing this crazy plugin mess. Why is the system looking inside my _64x plugin folder above when it is not mentioned in that place in the registry?

    (Thanks also for explaining about mp_pipeline. I haven't heard about it before.)
    Quote Quote  
  6. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    What exact version of Avisynth do you have installed?
    If D:\ is a non-system disk, your location is fine.

    In my system, the Plugins+ and Plugins64+ folders only contain the items that were installed with the Avisynth package.
    (I have left it like this, see image below)
    The Plugins and Plugins64 folders contain plugins that I have downloaded and placed there. Easier to keep it straight this way.

    It might be worth copying out any plugins you added to those folders to a safe place,
    uninstalling Avisynth, delete the registry entries, delete the official folder once you've checked and copied
    anything you need:
    Code:
    C:\Program Files (x86)\AviSynth+
    Make sure there are no old versions of Avisynth.dll in c:\windows\system32\
    Then install the latest Avisynth Plus
    https://www.videohelp.com/download/AviSynthPlus_3.7.3_20230715_vcredist.exe

    Add any downloaded plugins fresh from the downloaded zip files incase yours are mixed up. Add them to the folder I recommend above

    There are many ways to tell if a dll or exe is 32 or 64 bit:
    https://www.winhelponline.com/blog/find-out-if-a-program-exe-file-is-32-bit-or-64-bit/

    Regarding ffms2, as well as ffms2.dll, ffindex.exe, ffms2.avsi and depending in the package version, ffms2.lib should all be in the same folder
    Image Attached Thumbnails Click image for larger version

Name:	plus_folder.jpg
Views:	19
Size:	52.4 KB
ID:	78161  

    Click image for larger version

Name:	cleanup.jpg
Views:	23
Size:	73.0 KB
ID:	78162  

    Click image for larger version

Name:	avis_plus_cp.jpg
Views:	18
Size:	54.0 KB
ID:	78163  

    Click image for larger version

Name:	avis_plus.jpg
Views:	17
Size:	60.4 KB
ID:	78164  

    Last edited by davexnet; 5th Apr 2024 at 22:05.
    Quote Quote  
  7. Originally Posted by a1s2d3f4q1w2e3 View Post
    I agree that, given that they have the exact same names, it's very easy to mix up 32 and 64 bit plugins. I wish there was a way to tell from properties, or something.
    A long time ago I wrote a quick and dirty tool to check a binary for bitness. Since I retired from IT I've lost a lot of my code but lo and behold, I've posted this tool here on videohelp:

    https://forum.videohelp.com/threads/388030-LoadVirtualDubPlugin-never-works-%280xc1%29#post2512031
    Quote Quote  
  8. EDIT: With your help, I managed to finally fix it. Read my notes below, if you want.

    @davexnet:
    Remember, I don't have it "installed" in the traditional way. I used to download and "install" the official releases back in the day like you are doing until I came across the Repository I mentioned in the OP (https://forum.doom9.org/showthread.php?t=172124).

    The main advantage of this repository for me was (and I hope still is) to easily switch back and forth between different versions of the many different AviSynth types that are available. In my case, all I need is the ability to either try the 64-bit version (the best for speed), or, if I am using AviSynth plugins that only exist in 32-bit versions, the x86 AviSynth.

    Inside the folder with all the many AVISynths and the "main" plugin folders sits a batch file called setavs. If you run it, it presents you with options of what AVISynth "to choose". I used to make a choice (for example, "9 = Avisynth+ 3.7.0 (x86, r3382)") and it would report the following:

    Code:
    Installing AVSPLUS370_x86...
    
    setup for 64bit windows system...
    
    copying AVSPLUS370_x86 files to "C:\WINDOWS\SysWow64"...
    copy /y "D:\programs-non-setup\AvisynthRepository\AVSPLUS370_x86\avisynth.dll" "C:\WINDOWS\SysWow64"
            1 file(s) copied.
            1 file(s) copied.
    
    Writing "HKLM\SOFTWARE\Wow6432Node\Avisynth" /v "" /d "D:\programs-non-setup\AvisynthRepository\AVSPLUS370_x86"
    The operation completed successfully.
    
    Writing "HKLM\SOFTWARE\Wow6432Node\Avisynth" /v "PluginDir2_5" /d "D:\programs-non-setup\AvisynthRepository\AVSPLUS370_x86\plugins"
    The operation completed successfully.
    
    Writing "HKLM\SOFTWARE\Wow6432Node\Avisynth" /v "PluginDir+" /d "D:\programs-non-setup\AvisynthRepository\AVSPLUS370_x86\plugins"
    The operation completed successfully.
    
    adding more registry entries (wow64 mode)...
    The operation completed successfully.
    And we have discussed this in my previous replies.

    As you can see, it mentions it's copying files to SysWow64 (I looked inside the batch script and it appears that it is copying only the AviSynth.dll and DevIL.dll files from the chosen type of AVISynth folder to SysWow64. Reading on google (https://www.advancedinstaller.com/what-is-syswow64-folder-and-its-role.html) suggests that SysWOW64 folder is used for DLLs designed for 32-bit applications that are having to run on a 64-bit system, like mine.

    And, as I mentioned before, what's puzzling is that when I try to run the AVS, it appears that the system goes to the x64 folder, seemingly ignoring what I have in the registry under the HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\AviSynth key.

    I checked: I do not have any other installations (like in C:\Program Files (x86)\ or C:\Program Files) of AviSynth. Just this above-mentioned repository. It used to work just fine on my Win 8.1 laptop (64 bit). Now with this new machine running Win 11 (64 bit) it has this weird behavior.

    I do not want to do what you did, which is install AviSynth into C:\Program Files (x86), but rather I want to figure out what my system is doing that's causing this trip up.
    ====
    So, just to be thorough, I entered the path to the x64 plugins folder that the system insists upon going into on my machine into the regedit Find field and amazingly enough it found the Avisynth key located under HKEY_LOCAL_MACHINE\SOFTWARE\AviSynth key. This actually surprised me because looking in SOFTWARE (not SOFTWARE/WOW6432Node) before showed no such key. At least this points to a potential problem. So, I deleted that key branch. Then I found avisynth.dll and DevIL.dlls in the c:\windows\system32! Deleted those. (Also deleted them from SysWOW32).

    Now, let's check that I am not able to load my AVS script at all.
    ...
    Yep, confirmed, I am getting the AVI Import Filter error: (Unknown) (80040154)
    ...
    Now, running setavs batch again.
    Choosing 9, again.
    Checking regedit entries and not seeing AviSynth under HKLM\SOFTWARE\ but seeing it under HKLM\SOFTWARE\WOW6432Node.
    Running the path to the x64 plugins folder through the "Find".
    This time it's not finding anything, good.
    Checking C:\Windows\system32\ - nothing there, good.
    Checking C:\Windows\SysWow32\ - seeing AviSynth.dll there. Checking its date/time comparing to the x86 version in the AvisynthRepository folder - the same.
    Ok, good.

    Trying to run my AVS script.
    I just got the AVI Import Filter error: (Unknown) (80040154) which is exactly how it was when I did the OP.
    I remembered what you said about the situation with opening AVS scripts in 64 bit host programs vs 32 bit host programs and decided to look into that as well.
    And found that I was actually associating my avs files with the 64 bit version of VirtualDub instead of the 32bit version when clicking on them so at least we have figured out one part of my being an idiot. Ok, fixed. It is now opening and not throwing up the 800401054 error).

    Now I am back to the problem which didn't use to be the case on my Win 8.1 machine - that I didn't have to copy all my 32-bit AviSynth plugins to the individual AvisynthRepository AviSynth subfolders. The two "main plugin" folders (D:\programs-non-setup\AvisynthRepository\plugins and D:\programs-non-setup\AvisynthRepository\plugins64) could contain all my needed plugins and the system would search there automatically. Now it's clearly NOT doing this now.

    So, I am pulling out my old Win 8.1 laptop, which thankfully I still have, and I am looking at the registry there.

    And I found an important difference.
    This latest iteration of AvisynthRepository (setavs) is actually doing this: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Avisynth PluginDir2_5 is set to D:\programs-non-setup\AvisynthRepository\AVSPLUS370_x86\plugins
    On my Win 8.1 I am seeing that PluginDir2_5 is set to just D:\programs-non-setup\AvisynthRepository\plugins

    Ok, let's try to manually edit this.

    And YES! My problem is finally fixed.

    Analyzing what happened over the past couple of days suggests that I was stupidly trying to run my 32-bit-based AVS script in the 64-bit VirtualDub. Thank you for bringing up this to my attention. I'll have to figure out a way to prevent this stupidity from happening again. I wish the VDub icon I have associated with my AVS scripts would change color depending on which bit VDub I have associated by default.


    @andkar
    Your tool is EXCELLENT! Thank you very much for sharing it.
    Quote Quote  
  9. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Congrats for fixing it, AVisynth can be problematic enough by itself without having this extra switching functionality.
    Did you determine what caused the bad directory to appear at HKLM\SOFTWARE\WOW6432Node\Avisynth ??
    Problem with the later version of Setavs or the Universal Avisynth installer?

    There is a tool that may be helpful in the future, you can use it to check the integrity of the 32 and 64 bit plugins Avisynth
    knows about. It will tell you if it detects any problems (conflicts, bad version, missing dependencies,etc.)
    Run it from a command prompt or Powershell.
    https://www.videohelp.com/download/AVSMeter3090.7z
    Image Attached Thumbnails Click image for larger version

Name:	avsinfo.jpg
Views:	35
Size:	424.2 KB
ID:	78183  

    Last edited by davexnet; 7th Apr 2024 at 10:17.
    Quote Quote  
  10. Yes, I looked through this setavs.cmd batch file that appears in the latest version of "AvisynthRepository" and I see that it has a bunch of commands that basically builds the same path as the "Plugins+" key.
    Looking at my Win 8.1 copy of an earlier version of this package, cmd has a different bunch of commands. I don't have time right now to go through them carefully, but

    Older version:
    Code:
    ::batch script for fast switching of avisynth versions
    ::initial idea and work by Groucho2004
    ::modified by jones1913
    ::modified and extended by Groucho2004
    
    @echo off
    cls
    setlocal
    
    :Check administrative privileges
    fsutil dirty query %systemdrive% > nul
    if errorlevel 1 goto :noAdmin
    
    
    ::  ########################## Start Configuration #########################
    
    ::   The variable "AVS_SRC_DIR" needs to be set according to the location of
    ::   this batch file ("Option 1" and "Option 2" are mutually exclusive):
    
    ::   Option 1
    ::   When you unpack the repository and just want to create a shortcut to
    ::   the batch file, remove the colon from the beginning of the next line.
    set AVS_SRC_DIR=%~dp0
    
    ::   Option 2
    ::   If you want to run the batch file from a different directory
    ::   (i.e. a directory to which the "PATH" environment variable points),
    ::   use a fully qualified path to the source directory.
    ::   Example:
    ::   set AVS_SRC_DIR=E:\VideoTools\AvisynthRepository
    :set AVS_SRC_DIR=
    
    ::   Default plugin directories
    ::   If you leave them blank, the respective "plugin" directories within
    ::   the "AvisynthRepository" source directories will be used.
    set PLUGDIR32=D:\programs-non-setup\AvisynthRepository\plugins
    set PLUGDIR64=D:\programs-non-setup\AvisynthRepository\plugins64
    
    ::   Additional plugin directories (works only with Avisynth+)
    ::   If you leave them blank, only the default plugin directories (see above)
    ::   will be used.
    set PLUGDIR32PLUS=
    set PLUGDIR64PLUS=
    
    
    ::  **IMPORTANT:
    ::  If you have customized any of the above directories and their names contain
    ::  special characters such as '&', '(' or ')', enclose the variable and path
    ::  in double quotes and use the escape character '^' before the special character(s).
    ::  
    ::  Example 1:
    ::  set "AVS_SRC_DIR=C:\Program Files ^(x86^)\Avisynth"
    ::  
    ::  Example 2:
    ::  set "PLUGDIR32=C:\Program Files ^(x86^)\Avisynth\Plugins ^& avsi"
    
    
    ::  ########################### End Configuration ##########################
    
    
    
    if "%AVS_SRC_DIR%" == "" (
      echo.
      echo The source directory ^(AVS_SRC_DIR^) is not defined
      echo.
      goto :end
    )
    
    
    if /i %PROCESSOR_ARCHITECTURE%==x86 if not defined PROCESSOR_ARCHITEW6432 set winarch=x32
    
    if [%1]==[] goto :menu
    if /i %1==AVS258 (set avs=%1) & goto :install
    if /i %1==AVS260 (set avs=%1) & goto :install
    if /i %1==AVS261_Alpha (set avs=%1) & goto :install
    if /i %1==AVS260_ICL (set avs=%1) & goto :install
    if /i %1==AVS260_MT (set avs=%1) & goto :install
    if /i %1==AVSPLUS_x86 (set avs=%1) & (set avspl=true) & goto :install
    if /i %1==AVSPLUS_x64 (set avs=%1) & (set avspl=true) & goto :install
    echo.
    echo Unknown parameter.
    
    :menu
    echo.
    echo Which Avisynth version you want to install?
    echo (Or call this batch file next time directly with one of the below listed parameters.)
    echo.
    echo 1 = AVS258
    echo 2 = AVS260
    echo 3 = AVS261_Alpha
    echo 4 = AVS260_ICL
    echo 5 = AVS260_MT
    echo 6 = AVSPLUS_x86
    echo 7 = AVSPLUS_x64 *
    echo.
    echo 8 = Uninstall AVS x86
    echo 9 = Uninstall AVS x64
    echo.
    echo   *) AVS+ x64 can be installed in addition to one of the other (32 bit) versions.
    echo.
    set no=
    set /p no=[1-9] (leave blank and [Enter] for exit):
    if [%no%]==[] goto :cancel
    
    
    if %no%==1 set avs=AVS258
    if %no%==2 set avs=AVS260
    if %no%==3 set avs=AVS261_Alpha
    if %no%==4 set avs=AVS260_ICL
    if %no%==5 set avs=AVS260_MT
    if %no%==6 (set avs=AVSPLUS_x86) & set avspl=true
    if %no%==7 (set avs=AVSPLUS_x64) & set avspl=true
    if %no%==8 (set avs=AVSx86) & goto :uninstall
    if %no%==9 (set avs=AVSx64) & goto :uninstall
    echo.
    if [%avs%]==[] (echo Invalid input...
    goto :menu)
    
    :install
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    :: Remove trailing backslash if present
    if "%AVS_SRC_DIR:~-1%"=="\" SET AVS_SRC_DIR=%AVS_SRC_DIR:~0,-1%
    
    if "%PLUGDIR32%" == "" (
      set REGPLUGDIR32=%AVS_SRC_DIR%\%avs%\plugins
    ) else (
      set REGPLUGDIR32=%PLUGDIR32%
    )
    
    if "%PLUGDIR64%" == "" (
      set REGPLUGDIR64=%AVS_SRC_DIR%\%avs%\plugins
    ) else (
      set REGPLUGDIR64=%PLUGDIR64%
    )
    
    if "%PLUGDIR32PLUS%" == "" (
      set REGPLUGDIR32PLUS=%AVS_SRC_DIR%\%avs%\plugins
    ) else (
      set REGPLUGDIR32PLUS=%PLUGDIR32PLUS%
    )
    
    if "%PLUGDIR64PLUS%" == "" (
      set REGPLUGDIR64PLUS=%AVS_SRC_DIR%\%avs%\plugins
    ) else (
      set REGPLUGDIR64PLUS=%PLUGDIR64PLUS%
    )
    
    :: Remove trailing backslash if present
    if "%REGPLUGDIR32PLUS:~-1%"=="\" SET REGPLUGDIR32PLUS=%REGPLUGDIR32PLUS:~0,-1%
    if "%REGPLUGDIR64PLUS:~-1%"=="\" SET REGPLUGDIR64PLUS=%REGPLUGDIR64PLUS:~0,-1%
    if "%REGPLUGDIR32:~-1%"=="\" SET REGPLUGDIR32=%REGPLUGDIR32:~0,-1%
    if "%REGPLUGDIR64:~-1%"=="\" SET REGPLUGDIR64=%REGPLUGDIR64:~0,-1%
    
    echo Installing %avs%...
    echo.
    if defined winarch (
    echo setup for 32bit windows system...
    echo.
    if /i %avs%==AVSPLUS_x64 ( echo Attempt to install x64 AVS on x32 Windows.
    goto :cancel )
    echo copying %avs% files to "%WINDIR%\System32"...
    copy /y "%AVS_SRC_DIR%\%avs%\avisynth.dll" "%WINDIR%\System32"
    copy /y "%AVS_SRC_DIR%\%avs%\devil.dll" "%WINDIR%\System32"
    if errorlevel 1 ( echo Failed to copy files to "%WINDIR%\System32"
    goto :error )
    echo.
    echo Writing "HKLM\SOFTWARE\Avisynth" /v "" /d "%AVS_SRC_DIR%\%avs%"
    reg add "HKLM\SOFTWARE\Avisynth" /v "" /d "%AVS_SRC_DIR%\%avs%" /f
    echo.
    
    echo Writing "HKLM\SOFTWARE\Avisynth" /v "PluginDir2_5" /d "%REGPLUGDIR32%"
    reg add "HKLM\SOFTWARE\Avisynth" /v "PluginDir2_5" /d "%REGPLUGDIR32%" /f
    if errorlevel 1 ( echo Error on importing registry keys!
    goto :error )
    
    if "%REGPLUGDIR32PLUS%" GTR "" (
    echo.
    echo Writing "HKLM\SOFTWARE\Avisynth" /v "PluginDir+" /d "%REGPLUGDIR32PLUS%"
    reg add "HKLM\SOFTWARE\Avisynth" /v "PluginDir+" /d "%REGPLUGDIR32PLUS%" /f
    if errorlevel 1 ( echo Error on importing registry keys!
    goto :error )
    )
    
    call :regWin
    ) else (
    echo setup for 64bit windows system...
    echo.
    if /i %avs%==AVSPLUS_x64 (
    echo copying %avs% files to "%WINDIR%\System32"...
    copy /y "%AVS_SRC_DIR%\%avs%\avisynth.dll" "%WINDIR%\System32"
    copy /y "%AVS_SRC_DIR%\%avs%\devil.dll" "%WINDIR%\System32"
    if errorlevel 1 ( echo Failed to copy files to "%WINDIR%\System32"
    goto :error )
    echo.
    echo Writing "HKLM\SOFTWARE\Avisynth" /v "" /d "%AVS_SRC_DIR%\%avs%"
    reg add "HKLM\SOFTWARE\Avisynth" /v "" /d "%AVS_SRC_DIR%\%avs%" /f
    echo.
    
    echo Writing "HKLM\SOFTWARE\Avisynth" /v "PluginDir2_5" /d "%REGPLUGDIR64%"
    reg add "HKLM\SOFTWARE\Avisynth" /v "PluginDir2_5" /d "%REGPLUGDIR64%" /f
    if errorlevel 1 ( echo Error on importing registry keys!
    goto :error )
    
    if "%REGPLUGDIR64PLUS%" GTR "" (
    echo.
    echo Writing "HKLM\SOFTWARE\Avisynth" /v "PluginDir+" /d "%REGPLUGDIR64PLUS%"
    reg add "HKLM\SOFTWARE\Avisynth" /v "PluginDir+" /d "%REGPLUGDIR64PLUS%" /f
    if errorlevel 1 ( echo Error on importing registry keys!
    goto :error )
    )
    
    call :regWin
    ) else (
    echo copying %avs% files to "%WINDIR%\SysWow64"...
    echo copy /y "%AVS_SRC_DIR%\%avs%\avisynth.dll" "%WINDIR%\SysWow64"
    copy /y "%AVS_SRC_DIR%\%avs%\avisynth.dll" "%WINDIR%\SysWow64"
    copy /y "%AVS_SRC_DIR%\%avs%\devil.dll" "%WINDIR%\SysWow64"
    if errorlevel 1 ( echo Failed to copy files to "%WINDIR%\SysWow64"
    goto :error )
    echo.
    echo Writing "HKLM\SOFTWARE\Wow6432Node\Avisynth" /v "" /d "%AVS_SRC_DIR%\%avs%"
    reg add "HKLM\SOFTWARE\Wow6432Node\Avisynth" /v "" /d "%AVS_SRC_DIR%\%avs%" /f
    echo.
    
    echo Writing "HKLM\SOFTWARE\Wow6432Node\Avisynth" /v "PluginDir2_5" /d "%REGPLUGDIR32%"
    reg add "HKLM\SOFTWARE\Wow6432Node\Avisynth" /v "PluginDir2_5" /d "%REGPLUGDIR32%" /f
    if errorlevel 1 ( echo Error on importing registry keys!
    goto :error )
    
    if "%REGPLUGDIR32PLUS%" GTR "" (
    echo.
    echo Writing "HKLM\SOFTWARE\Wow6432Node\Avisynth" /v "PluginDir+" /d "%REGPLUGDIR32PLUS%"
    reg add "HKLM\SOFTWARE\Wow6432Node\Avisynth" /v "PluginDir+" /d "%REGPLUGDIR32PLUS%" /f
    if errorlevel 1 ( echo Error on importing registry keys!
    goto :error )
    )
    
    call :regWow64
    )
    )
    goto :end
    
    :regWin
    echo.
    echo adding more registry entries...
    reg add "HKLM\SOFTWARE\Classes\AVIFile\Extensions\AVS" /ve /d "{E6D6B700-124D-11D4-86F3-DB80AFD98778}" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}" /ve /d "AviSynth" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}\InProcServer32" /ve /d "AviSynth.dll" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}\InProcServer32" /v "ThreadingModel" /d "Apartment" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\Media Type\Extensions\.avs" /v "Source Filter" /d "{D3588AB0-0781-11CE-B03A-0020AF0BA770}" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\.avs" /ve /d "avsfile" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\.avsi" /ve /d "avs_auto_file" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\avsfile" /ve /d "AviSynth Script" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\avsfile\DefaultIcon" /ve /d "%WINDIR%\System32\AviSynth.dll,0" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\avs_auto_file" /ve /d "AviSynth Autoload Script" /f >nul 2>&1
    if defined avspl (reg add "HKLM\SOFTWARE\Classes\avs_auto_file\DefaultIcon" /ve  /d "%WINDIR%\System32\AviSynth.dll,1" /f
    ) else reg add "HKLM\SOFTWARE\Classes\avs_auto_file\DefaultIcon" /ve /d "%WINDIR%\System32\AviSynth.dll,0" /f
    goto :eof
    
    :regWow64
    echo.
    echo adding more registry entries (wow64 mode)...
    reg add "HKLM\SOFTWARE\Classes\AVIFile\Extensions\AVS" /ve /d "{E6D6B700-124D-11D4-86F3-DB80AFD98778}" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Wow6432Node\Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}" /ve /d "AviSynth" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Wow6432Node\Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}\InProcServer32" /ve /d "AviSynth.dll" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Wow6432Node\Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}\InProcServer32" /v "ThreadingModel" /d "Apartment" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Wow6432Node\Classes\Media Type\Extensions\.avs" /v "Source Filter" /d "{D3588AB0-0781-11CE-B03A-0020AF0BA770}" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\.avs" /ve /d "avsfile" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\.avsi" /ve /d "avs_auto_file" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\avsfile" /ve /d "AviSynth Script" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\avsfile\DefaultIcon" /ve /d "%WINDIR%\SysWow64\AviSynth.dll,0" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\avs_auto_file" /ve /d "AviSynth Autoload Script" /f >nul 2>&1
    if defined avspl (reg add "HKLM\SOFTWARE\Classes\avs_auto_file\DefaultIcon" /ve /d "%WINDIR%\SysWow64\AviSynth.dll,1" /f
    ) else reg add "HKLM\SOFTWARE\Classes\avs_auto_file\DefaultIcon" /ve /d "%WINDIR%\SysWow64\AviSynth.dll,0" /f
    goto :eof
    
    :uninstall
    echo.
    echo Remove %avs% .dll and registry entries from this system?
    set /p rm=[y/n]:
    if /i not [%rm%]==[y] goto :cancel
    echo.
    if defined winarch (
    if /i %avs%==AVSx64 ( echo Attempt to remove x64 AVS from x32 Windows.
    goto :cancel )
    echo removing %avs% files from "%WINDIR%\System32"...
    del "%WINDIR%\System32\avisynth.dll"
    del "%WINDIR%\System32\devil.dll"
    call :unregWin all
    ) else (
    if /i %avs%==AVSx64 (
    echo removing %avs% files from "%WINDIR%\System32"...
    del "%WINDIR%\System32\devil.dll"
    del "%WINDIR%\System32\avisynth.dll"
    if exist "%WINDIR%\SysWow64\avisynth.dll" (call :unregWin) else (
    call :unregWin all )
    ) else (
    echo removing %avs% files from "%WINDIR%\SysWow64"...
    del "%WINDIR%\SysWow64\avisynth.dll"
    del "%WINDIR%\SysWow64\devil.dll"
    if exist "%WINDIR%\System32\avisynth.dll" (call :unregWow64) else (
    call :unregWow64 all )
    )
    )
    goto :end
    
    :unregWin
    echo.
    echo removing registry entries...
    reg delete "HKLM\SOFTWARE\Avisynth" /f
    reg delete "HKLM\SOFTWARE\Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}" /f
    reg delete "HKLM\SOFTWARE\Classes\Media Type\Extensions\.avs" /f
    if [%1]==[all] call :unregAll
    goto :eof
    
    :unregWow64
    echo.
    echo removing registry entries (wow64 mode)...
    reg delete "HKLM\SOFTWARE\Wow6432Node\Avisynth" /f
    reg delete "HKLM\SOFTWARE\Wow6432Node\Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}" /f
    reg delete "HKLM\SOFTWARE\Wow6432Node\Classes\Media Type\Extensions\.avs" /f
    if [%1]==[all] call :unregAll
    goto :eof
    
    :unregAll
    echo.
    echo removing more avs registry entries...
    reg delete "HKLM\SOFTWARE\Classes\AVIFile\Extensions\AVS" /f
    reg delete "HKLM\SOFTWARE\Classes\.avs" /f
    reg delete "HKLM\SOFTWARE\Classes\.avsi" /f
    reg delete "HKLM\SOFTWARE\Classes\avsfile" /f
    reg delete "HKLM\SOFTWARE\Classes\avs_auto_file" /f
    goto :eof
    
    :noAdmin
    echo  This batch file must run with elevated privileges, so:
    echo.
    echo  Right click on it and chose "Run as administrator"
    goto :end
    
    :error
    echo.
    echo something went wrong...
    echo.
    
    :cancel
    echo.
    echo cancelled...
    echo.
    
    :end
    endlocal
    echo.
    pause
    New Version:
    Code:
    ::Batch script for fast switching of Avisynth versions
    ::Initial idea and work by Groucho2004
    ::Modified by jones1913
    ::Modified and extended by Groucho2004
    
    @echo off
    cls
    setlocal
    
    :Check administrative privileges
    fsutil dirty query %systemdrive% > nul
    if errorlevel 1 goto :noAdmin
    
    
    ::  ########################## Start Configuration #########################
    
    ::   The variable "AVS_SRC_DIR" must be set according to the location of
    ::   this batch file.
    
    ::   The simplest way to have this up and running is to copy the "AvisynthRepository"
    ::   directory to a location of your choice (avoid "Program Files" or "Program Files (x86)")
    ::   and create a shortcut to the "setavs.cmd" batch file in the root of "AvisynthRepository".
    
    ::   If you want to run the batch file from a different directory
    ::   (i.e. a directory to which the "PATH" environment variable points),
    ::   remove the "%~dp0" and use a fully qualified path to the source directory.
    ::   Example: "set AVS_SRC_DIR=E:\VideoTools\AvisynthRepository"
    set AVS_SRC_DIR=%~dp0
    
    
    ::   Default plugin directories
    ::   If you leave them blank, the respective "plugin" directories within
    ::   the "AvisynthRepository" source directories will be used.
    set PLUGDIR32=
    set PLUGDIR64=
    
    
    ::   Additional plugin directories (works only with Avisynth+)
    ::   If you leave them blank, only the default plugin directories (see above)
    ::   will be used.
    set PLUGDIR32PLUS=
    set PLUGDIR64PLUS=
    
    
    ::  **IMPORTANT:
    ::  If you have customized any of the above directories and their names contain
    ::  special characters such as '&', '(' or ')', enclose the variable and path
    ::  in double quotes and use the escape character '^' before the special character(s).
    ::  
    ::  Example 1:
    ::  set "AVS_SRC_DIR=C:\Program Files ^(x86^)\Avisynth"
    ::  
    ::  Example 2:
    ::  set "PLUGDIR32=C:\Program Files ^(x86^)\Avisynth\Plugins ^& avsi"
    
    
    ::  ########################### End Configuration ##########################
    
    
    
    if "%AVS_SRC_DIR%" == "" (
      echo.
      echo The source directory ^(AVS_SRC_DIR^) is not defined.
      echo Please read the instructions above.
      echo.
      goto :end
    )
    
    if /i %PROCESSOR_ARCHITECTURE%==x86 if not defined PROCESSOR_ARCHITEW6432 set winarch=x32
    
    :: Remove trailing backslash if present
    if "%AVS_SRC_DIR:~-1%"=="\" SET AVS_SRC_DIR=%AVS_SRC_DIR:~0,-1%
    
    echo.
    echo  Installed Avisynth version(s):
    echo.
    if defined winarch (
    	"%AVS_SRC_DIR%\Tools\AVSVersion32.exe"
    ) else (
    	"%AVS_SRC_DIR%\Tools\AVSVersion32.exe"
    	echo.
    	"%AVS_SRC_DIR%\Tools\AVSVersion64.exe"
    )
    echo.
    
    echo.
    echo  Select the Avisynth version you want to install/uninstall:
    echo.
    echo    1 = Avisynth      2.5.8
    echo    2 = Avisynth      2.6.0
    echo    3 = Avisynth      2.6.1 (Alpha)
    echo    4 = Avisynth      2.6.0 (SEt's multi-threaded build)
    echo.
    
    echo    5 = Avisynth+     0.1.0 (x86, r2772)
    echo    6 = Avisynth+     0.1.0 (x64, r2772)
    echo    7 = Avisynth+ XP  3.7.0 (x86, r3382)
    echo    8 = Avisynth+ XP  3.7.0 (x64, r3382)
    echo    9 = Avisynth+     3.7.0 (x86, r3382)
    echo   10 = Avisynth+     3.7.0 (x64, r3382)
    
    echo.
    echo   13 = Uninstall Avisynth x86
    echo   14 = Uninstall Avisynth x64
    echo.
    echo   NOTE: 64 bit versions can be installed alongside 32 bit versions.
    echo.
    echo.
    set no=
    set /p no=  [1-12] (leave blank and [Enter] to exit): 
    if [%no%]==[] goto :cancel
    
    
    if %no%==1 set avs=AVS258
    if %no%==2 set avs=AVS260
    if %no%==3 set avs=AVS261_Alpha
    if %no%==4 set avs=AVS260_MT
    
    if %no%==5  (set avs=AVSPLUS010_x86) & set avspl=true
    if %no%==6  (set avs=AVSPLUS010_x64) & set avspl=true
    if %no%==7  (set avs=AVSPLUS370_x86_XP) & set avspl=true
    if %no%==8  (set avs=AVSPLUS370_x64_XP) & set avspl=true
    if %no%==9  (set avs=AVSPLUS370_x86) & set avspl=true
    if %no%==10 (set avs=AVSPLUS370_x64) & set avspl=true
    
    
    if %no%==13 (set avs=AVSx86) & goto :uninstall
    if %no%==14 (set avs=AVSx64) & goto :uninstall
    echo.
    if [%avs%]==[] (echo Invalid input...
    	goto :menu)
    
    if %avs%==AVSPLUS010_x64 set x64=true
    if %avs%==AVSPLUS370_x64 set x64=true
    if %avs%==AVSPLUS370_x64_XP set x64=true
    if %avs%==AVSPLUS370_x64 set x64=true
    
    :install
    
    :: Remove trailing backslash if present
    if "%AVS_SRC_DIR:~-1%"=="\" SET AVS_SRC_DIR=%AVS_SRC_DIR:~0,-1%
    
    if "%PLUGDIR32%" == "" (
      set REGPLUGDIR32=%AVS_SRC_DIR%\%avs%\plugins
    ) else (
      set REGPLUGDIR32=%PLUGDIR32%
    )
    
    if "%PLUGDIR64%" == "" (
      set REGPLUGDIR64=%AVS_SRC_DIR%\%avs%\plugins
    ) else (
      set REGPLUGDIR64=%PLUGDIR64%
    )
    
    if "%PLUGDIR32PLUS%" == "" (
      set REGPLUGDIR32PLUS=%AVS_SRC_DIR%\%avs%\plugins
    ) else (
      set REGPLUGDIR32PLUS=%PLUGDIR32PLUS%
    )
    
    if "%PLUGDIR64PLUS%" == "" (
      set REGPLUGDIR64PLUS=%AVS_SRC_DIR%\%avs%\plugins
    ) else (
      set REGPLUGDIR64PLUS=%PLUGDIR64PLUS%
    )
    
    :: Remove trailing backslash if present
    if "%REGPLUGDIR32PLUS:~-1%"=="\" SET REGPLUGDIR32PLUS=%REGPLUGDIR32PLUS:~0,-1%
    if "%REGPLUGDIR64PLUS:~-1%"=="\" SET REGPLUGDIR64PLUS=%REGPLUGDIR64PLUS:~0,-1%
    if "%REGPLUGDIR32:~-1%"=="\" SET REGPLUGDIR32=%REGPLUGDIR32:~0,-1%
    if "%REGPLUGDIR64:~-1%"=="\" SET REGPLUGDIR64=%REGPLUGDIR64:~0,-1%
    
    echo Installing %avs%...
    echo.
    if defined winarch (
    	echo setup for 32bit windows system...
    	echo.
    
    	if defined x64 ( echo Attempt to install x64 AVS on x32 Windows.
    		goto :cancel )
    
    	echo copying %avs% files to "%WINDIR%\System32"...
    	copy /y "%AVS_SRC_DIR%\%avs%\avisynth.dll" "%WINDIR%\System32"
    	copy /y "%AVS_SRC_DIR%\%avs%\devil.dll" "%WINDIR%\System32"
    	if errorlevel 1 ( echo Failed to copy files to "%WINDIR%\System32"
    		goto :error )
    	echo.
    	echo Writing "HKLM\SOFTWARE\Avisynth" /v "" /d "%AVS_SRC_DIR%\%avs%"
    	reg add "HKLM\SOFTWARE\Avisynth" /v "" /d "%AVS_SRC_DIR%\%avs%" /f
    	echo.
    
    	echo Writing "HKLM\SOFTWARE\Avisynth" /v "PluginDir2_5" /d "%REGPLUGDIR32%"
    	reg add "HKLM\SOFTWARE\Avisynth" /v "PluginDir2_5" /d "%REGPLUGDIR32%" /f
    	if errorlevel 1 ( echo Error on importing registry keys!
    		goto :error )
    
    	if "%REGPLUGDIR32PLUS%" GTR "" (
    		echo.
    		echo Writing "HKLM\SOFTWARE\Avisynth" /v "PluginDir+" /d "%REGPLUGDIR32PLUS%"
    		reg add "HKLM\SOFTWARE\Avisynth" /v "PluginDir+" /d "%REGPLUGDIR32PLUS%" /f
    		if errorlevel 1 ( echo Error on importing registry keys!
    			goto :error )
    	)
    
    	call :regWin
    ) else (
    	echo setup for 64bit windows system...
    	echo.
    	if defined x64 (
    		echo copying %avs% files to "%WINDIR%\System32"...
    		copy /y "%AVS_SRC_DIR%\%avs%\avisynth.dll" "%WINDIR%\System32"
    		copy /y "%AVS_SRC_DIR%\%avs%\devil.dll" "%WINDIR%\System32"
    		if errorlevel 1 ( echo Failed to copy files to "%WINDIR%\System32"
    			goto :error )
    		echo.
    		echo Writing "HKLM\SOFTWARE\Avisynth" /v "" /d "%AVS_SRC_DIR%\%avs%"
    		reg add "HKLM\SOFTWARE\Avisynth" /v "" /d "%AVS_SRC_DIR%\%avs%" /f
    		echo.
    
    		echo Writing "HKLM\SOFTWARE\Avisynth" /v "PluginDir2_5" /d "%REGPLUGDIR64%"
    		reg add "HKLM\SOFTWARE\Avisynth" /v "PluginDir2_5" /d "%REGPLUGDIR64%" /f
    		if errorlevel 1 ( echo Error on importing registry keys!
    			goto :error )
    
    		if "%REGPLUGDIR64PLUS%" GTR "" (
    			echo.
    			echo Writing "HKLM\SOFTWARE\Avisynth" /v "PluginDir+" /d "%REGPLUGDIR64PLUS%"
    			reg add "HKLM\SOFTWARE\Avisynth" /v "PluginDir+" /d "%REGPLUGDIR64PLUS%" /f
    			if errorlevel 1 ( echo Error on importing registry keys!
    				goto :error )
    		)
    
    		call :regWin
    	) else (
    		echo copying %avs% files to "%WINDIR%\SysWow64"...
    		echo copy /y "%AVS_SRC_DIR%\%avs%\avisynth.dll" "%WINDIR%\SysWow64"
    		copy /y "%AVS_SRC_DIR%\%avs%\avisynth.dll" "%WINDIR%\SysWow64"
    		copy /y "%AVS_SRC_DIR%\%avs%\devil.dll" "%WINDIR%\SysWow64"
    		if errorlevel 1 ( echo Failed to copy files to "%WINDIR%\SysWow64"
    			goto :error )
    		echo.
    		echo Writing "HKLM\SOFTWARE\Wow6432Node\Avisynth" /v "" /d "%AVS_SRC_DIR%\%avs%"
    		reg add "HKLM\SOFTWARE\Wow6432Node\Avisynth" /v "" /d "%AVS_SRC_DIR%\%avs%" /f
    		echo.
    
    		echo Writing "HKLM\SOFTWARE\Wow6432Node\Avisynth" /v "PluginDir2_5" /d "%REGPLUGDIR32%"
    		reg add "HKLM\SOFTWARE\Wow6432Node\Avisynth" /v "PluginDir2_5" /d "%REGPLUGDIR32%" /f
    		if errorlevel 1 ( echo Error on importing registry keys!
    			goto :error )
    
    		if "%REGPLUGDIR32PLUS%" GTR "" (
    			echo.
    			echo Writing "HKLM\SOFTWARE\Wow6432Node\Avisynth" /v "PluginDir+" /d "%REGPLUGDIR32PLUS%"
    			reg add "HKLM\SOFTWARE\Wow6432Node\Avisynth" /v "PluginDir+" /d "%REGPLUGDIR32PLUS%" /f
    			if errorlevel 1 ( echo Error on importing registry keys!
    				goto :error )
    		)
    
    		call :regWow64
    	)
    )
    goto :end
    
    :regWin
    echo.
    echo adding more registry entries...
    reg add "HKLM\SOFTWARE\Classes\AVIFile\Extensions\AVS" /ve /d "{E6D6B700-124D-11D4-86F3-DB80AFD98778}" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}" /ve /d "AviSynth" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}\InProcServer32" /ve /d "AviSynth.dll" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}\InProcServer32" /v "ThreadingModel" /d "Apartment" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\Media Type\Extensions\.avs" /v "Source Filter" /d "{D3588AB0-0781-11CE-B03A-0020AF0BA770}" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\.avs" /ve /d "avsfile" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\.avsi" /ve /d "avs_auto_file" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\avsfile" /ve /d "AviSynth Script" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\avsfile\DefaultIcon" /ve /d "%WINDIR%\System32\AviSynth.dll,0" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\avs_auto_file" /ve /d "AviSynth Autoload Script" /f >nul 2>&1
    if defined avspl (reg add "HKLM\SOFTWARE\Classes\avs_auto_file\DefaultIcon" /ve  /d "%WINDIR%\System32\AviSynth.dll,1" /f
    	) else reg add "HKLM\SOFTWARE\Classes\avs_auto_file\DefaultIcon" /ve /d "%WINDIR%\System32\AviSynth.dll,0" /f
    goto :eof
    
    :regWow64
    echo.
    echo adding more registry entries (wow64 mode)...
    reg add "HKLM\SOFTWARE\Classes\AVIFile\Extensions\AVS" /ve /d "{E6D6B700-124D-11D4-86F3-DB80AFD98778}" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Wow6432Node\Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}" /ve /d "AviSynth" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Wow6432Node\Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}\InProcServer32" /ve /d "AviSynth.dll" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Wow6432Node\Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}\InProcServer32" /v "ThreadingModel" /d "Apartment" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Wow6432Node\Classes\Media Type\Extensions\.avs" /v "Source Filter" /d "{D3588AB0-0781-11CE-B03A-0020AF0BA770}" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\.avs" /ve /d "avsfile" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\.avsi" /ve /d "avs_auto_file" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\avsfile" /ve /d "AviSynth Script" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\avsfile\DefaultIcon" /ve /d "%WINDIR%\SysWow64\AviSynth.dll,0" /f >nul 2>&1
    reg add "HKLM\SOFTWARE\Classes\avs_auto_file" /ve /d "AviSynth Autoload Script" /f >nul 2>&1
    if defined avspl (reg add "HKLM\SOFTWARE\Classes\avs_auto_file\DefaultIcon" /ve /d "%WINDIR%\SysWow64\AviSynth.dll,1" /f
    	) else reg add "HKLM\SOFTWARE\Classes\avs_auto_file\DefaultIcon" /ve /d "%WINDIR%\SysWow64\AviSynth.dll,0" /f
    goto :eof
    
    :uninstall
    echo.
    echo Remove %avs% .dll and registry entries from this system?
    set /p rm=[y/n]: 
    if /i not [%rm%]==[y] goto :cancel
    echo.
    if defined winarch (
    	if /i %avs%==AVSx64 ( echo Attempt to remove x64 AVS from x32 Windows.
    		goto :cancel )
    	echo removing %avs% files from "%WINDIR%\System32"...
    	del "%WINDIR%\System32\avisynth.dll"
    	del "%WINDIR%\System32\devil.dll"
    	call :unregWin all
    ) else (
    	if /i %avs%==AVSx64 (
    		echo removing %avs% files from "%WINDIR%\System32"...
    		del "%WINDIR%\System32\devil.dll"
    		del "%WINDIR%\System32\avisynth.dll"
    		if exist "%WINDIR%\SysWow64\avisynth.dll" (call :unregWin) else (
    			call :unregWin all )
    	) else (
    		echo removing %avs% files from "%WINDIR%\SysWow64"...
    		del "%WINDIR%\SysWow64\avisynth.dll"
    		del "%WINDIR%\SysWow64\devil.dll"
    		if exist "%WINDIR%\System32\avisynth.dll" (call :unregWow64) else (
    			call :unregWow64 all )
    	)
    )
    goto :end
    	
    :unregWin
    echo.
    echo removing registry entries...
    reg delete "HKLM\SOFTWARE\Avisynth" /f
    reg delete "HKLM\SOFTWARE\Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}" /f
    reg delete "HKLM\SOFTWARE\Classes\Media Type\Extensions\.avs" /f
    if [%1]==[all] call :unregAll
    goto :eof
    
    :unregWow64
    echo.
    echo removing registry entries (wow64 mode)...
    reg delete "HKLM\SOFTWARE\Wow6432Node\Avisynth" /f
    reg delete "HKLM\SOFTWARE\Wow6432Node\Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}" /f
    reg delete "HKLM\SOFTWARE\Wow6432Node\Classes\Media Type\Extensions\.avs" /f
    if [%1]==[all] call :unregAll
    goto :eof
    
    :unregAll
    echo.
    echo removing more avs registry entries...
    reg delete "HKLM\SOFTWARE\Classes\AVIFile\Extensions\AVS" /f
    reg delete "HKLM\SOFTWARE\Classes\.avs" /f
    reg delete "HKLM\SOFTWARE\Classes\.avsi" /f
    reg delete "HKLM\SOFTWARE\Classes\avsfile" /f
    reg delete "HKLM\SOFTWARE\Classes\avs_auto_file" /f
    goto :eof
    
    :noAdmin
    echo  This batch file must run with elevated privileges, so:
    echo.
    echo  Right click on it and chose "Run as administrator"
    goto :end
    
    :error
    echo.
    echo something went wrong...
    echo.
    
    :cancel
    echo.
    echo cancelled...
    echo.
    
    :end
    endlocal
    echo.
    pause
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!