1.

Solve : %appdata% use within batch help?

Answer»

I made a batch earlier today to clean my IMVU http game cache that grows over time with no built in size management, and as it grows it starts to lag out performance as at one point it was filled with 5.3GB of cache mostly junk gathered throughout gameplay which appears to act like a precache for the game. However when you end up with over 100,000 of these small files the performance benefit of these files being local disappears. I made a copy of IMVU before and after so I could restore the 5.3GB of cache data back and it LOADS rooms etc more than twice as fast by not seeking the data locally but instead redownloading it off the IMVU servers over 25/5 mbps broadband. The batch I made for this specific COMPUTER I just gave it the full path of c:\Users\AX4\AppData\Roaming\IMVU\ and told it to remove the HttpCache directory and all contents silently. Then recreate an empty directory back at that location for the IMVU client to write to when the game is run again.

Decided after I made the batch that why dont i figure out a WAY to make it not system user profile specific. Did some research into the %appdata% use so that it can be dynamic and work for all, but I'm running into syntax error on use and its probably something really simple, but after google searching I figure why not check with you all here to have you point out how to correct for this issue.

Told my friends about cleaning out my IMVU cache made it so much better. Now they want to run it too, but I figured why not make it for anyone to use without having to alter the batch file to be user specific.

Quote

The filename, directory name, or volume label syntax is incorrect.


***************************
Erasing IMVU Http Cache
Please Wait...
***************************


Note: The pause after the rd /s /q HttpCache is only here for debugging and WOULD be removed later. I placed it there to capture the error condition.

echo off
color 4f
cls
@echo.
@echo. ***************************
@echo. IMVU Http Cache Eraser
@echo. ***************************
@echo. Version 1.0
@echo. 6/1/2016
@echo.
pause
color e0
cls
cd c:\%AppData%\Roaming\IMVU\
@echo.
@echo.
@echo. ***************************
@echo. Erasing IMVU Http Cache
@echo. Please Wait...
@echo. ***************************
@echo.
@echo.
rd /s /q HttpCache
pause
md HttpCache
color 3f
cls
@echo. **************************
@echo. IMVU Http Cache Erased
@echo. **************************
@echo.
@echo.
pauseThe expansion of the %appdata% environment variable already contains the system drive letter, colon and backslash e.g. C:\ at the beginning so you don't need it like in the code line following. It will make the CD command point to a non-existent folder and give the error you saw.

cd c:\%AppData%\Roaming\IMVU\
Thanks Salmon for assisting... But its still not happy.

Using Windows 7 Home Premium 64-bit by the way just in case that make a difference somehow.

I tried

cd %AppData%\Roaming\IMVU\
cd \%AppData%\Roaming\IMVU\
cd C:\%AppData%\Roaming\IMVU\

And the path is correct to this folder at the deeper target of Roaming\IMVU\

Changed it to cd %AppData%\Roaming\IMVU\ as suggested and it says path not found.


Quote
The system cannot find the path specified.


***************************
Erasing IMVU Http Cache
Please Wait...
***************************


The system cannot find the file specified.
Press any key to continue . . .



Here is my system paths from SET:
Quote
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\AX4>set
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\AX4\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=AX4-PC
ComSpec=C:\Windows\system32\cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\AX4
LOCALAPPDATA=C:\Users\AX4\AppData\Local
LOGONSERVER=\\AX4-PC
NUMBER_OF_PROCESSORS=4
OS=Windows_NT
Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32
\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=AMD64 Family 16 Model 5 Stepping 2, AuthenticAMD
PROCESSOR_LEVEL=16
PROCESSOR_REVISION=0502
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\AX4\AppData\Local\Temp
TMP=C:\Users\AX4\AppData\Local\Temp
USERDOMAIN=AX4-PC
USERNAME=AX4
USERPROFILE=C:\Users\AX4
windir=C:\Windows

C:\Users\AX4>

[attachment deleted by admin to conserve space]Environment variable may not expand %APPDATA% to the Application folder
https://support.microsoft.com/en-us/kb/329308
Quote
This behavior is caused by a problem in Shell32.dll.
Hello Geek ... it looks like that bug is in reference to:

Quote
Article ID: 329308 - Last Review: 02/28/2007 23:02:00 - Revision: 2.3
Applies to

Microsoft Windows 2000 Advanced Server
Microsoft Windows 2000 Server
Microsoft Windows 2000 Professional Edition
Microsoft Windows XP Home Edition
Microsoft Windows XP Professional
Windows Server 2008 Datacenter without Hyper-V
Windows Server 2008 Enterprise without Hyper-V
Windows Server 2008 for Itanium-Based Systems
Windows Server 2008 Standard without Hyper-V
Windows Server 2008 Datacenter
Windows Server 2008 Enterprise
Windows Server 2008 Standard
Windows Web Server 2008

Keywords:

kbprb KB329308

And I'm running Windows 7 64-bit

I didnt catch this fact that it was for different OS until I went to the suggested fix and there was no Properties option and I was like hmmm why is it missing and then I looked further and saw that it was regarding other affected OS's. Quote
APPDATA=C:\Users\AX4\AppData\Roaming
Quote
Changed it to cd %AppData%\Roaming\IMVU\ as suggested and it says path not found.

That expands to C:\Users\AX4\AppData\Roaming\Roaming\IMVU\ .

You want
Code: [Select]%APPDATA%\IMVUCOOL! Thanks BC

That was the fix!

Thanks everyone. I thought it would only bring you in to the AppData depth of the path. Did not know that any subfolders could be targeted without exclusive pathing. I thought the path had to be exclusive to be specific to Roaming prior to IMVU.

Correction to my last response

Quote
Did not know that any subfolders could be targeted without exclusive pathing. I thought the path had to be exclusive to be specific to Roaming prior to IMVU.

I realized I was wrong in my statement. Looking back here I see that %AppData% pointed direct to the Roaming folder of the profile
Quote
APPDATA=C:\Users\AX4\AppData\Roaming

The path is specific as seen in SET

The fix to batch worked perfect, so issue is solved, but in case anyone ever gets here and reads the entire thread, they will see this correction.Windows XP SP3 C:\Documents and Settings\username\Application Data

Windows 7 SP2 C:\Users\username\AppData\Roaming

Windows 10 C:\Users\username\AppData\Roaming


Usernames can have spaces and other nasties, so wrap it in double quotes to protect against that.


Code: [Select]"%APPDATA%\IMVU"Cool Thanks Foxidrive ... I overlooked that.

The good thing is that my friends computers who also run IMVU dont have spaces so the original form worked like a charm, but its good to state it here to fix that line to include the " " in case someone else runs with the batch to use as their own that finds this online.



Discussion

No Comment Found