scripting


  1. Posts : 7
    Windows 7 Ultimate x64
       #1

    scripting


    (Admin, feel free to move to more appropriate thread)

    I wrote a script to download and update some files on my system when i was using my xp installation. It reads a list of URLs and descriptors from a txt file then downloads the files using wget for windows then looks up a key in the registry to tell where to extract the files to. The script worked fine under xp but under 7 it seems to fail when trying to lookup the registry key. I tried a couple of things to get it working but can't seem to figure it out, the attached file is the original version that was working under xp.
    scripting Attached Files
      My Computer


  2. Posts : 9,582
    Windows 8.1 Pro RTM x64
       #2

    Hi smokes2345,

    For reference, here is the code:

    Code:
    @echo off
    set urlFile=addons.list.txt
    set tmpFile=tmp.updater.zip
    set computer=%computername%
    set regpath="HKLM\Software\Wow6432Node\Blizzard Entertainment\World of Warcraft"
    set regkey=InstallPath
    if not exist cache mkdir cache
    ::reg query "%regpath%" /v %regkey%
    echo REGPATH %regpath%
    pause
    FOR /F "tokens=3* delims= " %%a in ('Reg Query %regpath% /v "%regkey%" ^| find /i "%regkey%"') do set installDir=%%a
    echo Installdir is %installDir%
    pause
    for /F "tokens=1,2" %%a in (%urlFile%) do (
    echo Installing %%a to %installDir%\Interface\Addons\...
    wget -N %%b -P cache )
    start /D "%installDir%" Launcher.exe
    for /r cache %%X in (*) do (
    echo Inflating %%X
    7za x "%%X" -o"%installDir%\Interface\Addons\" -y )
    REM ::if not exist "cache\%%a.zip" ( move %%a.tmp.zip cache\%%a.zip ) ELSE ( if NOT "cache\%%a.zip" EQU "%%a.tmp.zip" ( move %%a.tmp.zip cache\%%a.zip ) ELSE del %%a.tmp.zip ))
    ::start /D "%installDir%" Launcher.exe
    Looking through the code, I can see that it refers to the HKLM branch of the registry. Are you running the file as a standard user? If so, try running it in elevated mode. Right-click on it and select Run as administrator and provide administrative credentials. See how that goes, but I'm sure that a scripting guru will drop by soon.
      My Computer


  3. Posts : 7
    Windows 7 Ultimate x64
    Thread Starter
       #3

    Running the query by hand as admin or regular user works fine, the script returns a syntax error for the query when run in the script. I tried changing some of the encapsulation (moved the ' around) and now the query completes but then the shell says it can't find 'FIND'.
      My Computer


  4. Posts : 7
    Windows 7 Ultimate x64
    Thread Starter
       #4

    Moving the ' and " around i got it to run without error but the installDir variable is empty at the end of the loop. I think adjusting the tokens and delim might fix it. new code:

    @echo off
    set urlFile=addons.list.txt
    set tmpFile=tmp.updater.zip

    set computer=%computername%
    set regpath="HKLM\Software\Wow6432Node\Blizzard Entertainment\World of Warcraft"
    set regkey=InstallPath

    if not exist cache mkdir cache
    ::reg query "%regpath%" /v %regkey%
    echo REGPATH %regpath%

    FOR /F "tokens=3* delims= " %%a in ("Reg Query %regpath% /v %regkey% ^| find /i %regkey%") do (set installDir=%%a;echo %%a)
    echo Installdir is %installDir%

    pause
    for /F "tokens=1,2" %%a in (%urlFile%) do (
    echo Installing %%a to %installDir%\Interface\Addons\...
    wget -N %%b -P cache )

    start /D "%installDir%" Launcher.exe

    for /r cache %%X in (*) do (
    echo Inflating %%X
    7za x "%%X" -o"%installDir%\Interface\Addons\" -y )
    REM ::if not exist "cache\%%a.zip" ( move %%a.tmp.zip cache\%%a.zip ) ELSE ( if NOT "cache\%%a.zip" EQU "%%a.tmp.zip" ( move %%a.tmp.zip cache\%%a.zip ) ELSE del %%a.tmp.zip ))

    ::start /D "%installDir%" Launcher.exe
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 10:30.
Find Us