|
Answer» here's the code:
wmpshelloff.bat Code: [Select]if %0:~-5% == "f.bat" (
rem Unregistering WMP SHELL Integration regsvr32 /u wmpshell.dll set ren=%0:on=off% )else ( echo no rem REGISTERING WMP SHELL Integration regsvr32 wmpshell.dll set ren=%0:off=on% ) RENAME %0 %ren%WHY DOES IT NOT WORK!?What is displayed when you run the batch ? are there error messages ? Can you paste them in here
GrahamCode: [Select]C:\dos>wmpshelloff.bat
C:\dos>if wmpshelloff.bat:~-5 == "f.bat" ( rem Unregistering WMP SHELL Integration regsvr32 /u wmpshell.dll set ren=wmpshelloff.bat:on=off ) else ( echo no rem Registering WMP SHELL Integration regsvr32 wmpshell.dll set ren=wmpshelloff.bat:off=on ) no
C:\dos>rename wmpshelloff.bat wmpshelloff.bat:off=on The SYNTAX of the command is incorrect.
C:\dos>Stramge, variable expansion seems off yet it is set to on from the registry... Does it work for You? It's supposed to unregister wmpshell.dll, I'm USING XP SP2 BTWThe %0 parameter does not include the file extension which makes your if statement shaky. The following SNIPPET does what you need but the cmd processor does not like executing files to disappear; something to do with handles and all that .
Code: [Select]setlocal enabledelayedexpansion set pgm=%0 if %0:~-1% == "f" (
rem Unregistering WMP SHELL Integration regsvr32 /u wmpshell.dll set ren=!pgm:on=off! )else ( echo no rem Registering WMP SHELL Integration regsvr32 wmpshell.dll set ren=!pgm:off=on! ) rename %0.bat %ren%.bat
Thanks for the help all I gave up using %0 at all because if you open it from the gui it brakes down... i devised an easier way, albeit it rquires user input Code: [Select]@echo off
echo Hit a key to: set /p wmpshell=[R]egister or [U]nregister Wmp shell: if not '%wmpshell%'=='' set choice=%choice:~0,1% rem Unregistering WMP SHELL Integration if '%wmpshell%'=='U' regsvr32 /u wmpshell.dll if '%wmpshell%'=='u' regsvr32 /u wmpshell.dll rem Registering WMP SHELL Integration if '%wmpshell%'=='R' regsvr32 wmpshell.dll if '%wmpshell%'=='r' regsvr32 wmpshell.dll
|