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
smokes2345

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
Dwarf

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
smokes2345

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
smokes2345

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
Thread Forum
scripting the setup
Hi Brink, I know this is an old threat but since you really seem to be an expert in this field, I am still replying to it. I need to make a script (for windows 7/8) to activate the "file History" (windows 8) and "backup & Restore" (Windows 7). I know all the parameters in advance. the idea would...
Backup and Restore
Scripting host
I get errors in ie & even group policy editor .. . I'd love to have a radical way to get rid of those script errors. After having read many solutions, i haven't foun the right one.
Customization
IE9 and Cross-site Scripting
I have IE 9. Does anyone know if I can shut this off? This happens when I try to click to see my profile. A pop up of my profile would come up. TY
Browsers & Mail
Scripting?
Is it possiable to create a script in Windows 7 that will enter commands into Command Prompt? And how would i go about doing htis?
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 11:59.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App