Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: scripting


22 Dec 2010   #1

Windows 7 Ultimate x64
 
 
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.




Attached Files
File Type: bat addon_update_xp.bat (960 Bytes, 16 views)
My System SpecsSystem Spec
.

22 Dec 2010   #2

Windows 8.1 Pro RTM x64
 
 

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 System SpecsSystem Spec
22 Dec 2010   #3

Windows 7 Ultimate x64
 
 

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 System SpecsSystem Spec
.


22 Dec 2010   #4

Windows 7 Ultimate x64
 
 

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 System SpecsSystem Spec
Reply

 scripting




Thread Tools



Similar help and support threads for2: scripting
Thread Forum
Scripting host Customization
Cross site scripting General Discussion
Solved Looking for a software scripting tool Software
Solved Anybody know VB Scripting? Trying to fix an obsolete Gadget. Gadgets
Scripting? General Discussion

Our Sites

Site Links

About Us

Find 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 01:42 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33