Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: %appdata% use within batch help  (Read 22839 times)

0 Members and 1 Guest are viewing this topic.

DaveLembke

    Topic Starter


    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
%appdata% use within batch help
« on: June 01, 2016, 10:09:50 AM »
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.
pause

Salmon Trout

  • Guest
Re: %appdata% use within batch help
« Reply #1 on: June 01, 2016, 11:46:05 AM »
The 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\

DaveLembke

    Topic Starter


    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: %appdata% use within batch help
« Reply #2 on: June 01, 2016, 12:10:48 PM »
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]

Geek-9pm


    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: %appdata% use within batch help
« Reply #3 on: June 01, 2016, 12:28:29 PM »
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.

DaveLembke

    Topic Starter


    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: %appdata% use within batch help
« Reply #4 on: June 01, 2016, 12:38:37 PM »
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.  ;D

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: %appdata% use within batch help
« Reply #5 on: June 01, 2016, 01:09:50 PM »
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%\IMVU
I was trying to dereference Null Pointers before it was cool.

DaveLembke

    Topic Starter


    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: %appdata% use within batch help
« Reply #6 on: June 01, 2016, 01:21:11 PM »
COOL! 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.

 8)

DaveLembke

    Topic Starter


    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: %appdata% use within batch help
« Reply #7 on: June 02, 2016, 12:37:22 PM »
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.

Salmon Trout

  • Guest
Re: %appdata% use within batch help
« Reply #8 on: June 02, 2016, 01:18:31 PM »
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



foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: %appdata% use within batch help
« Reply #9 on: June 08, 2016, 12:00:57 PM »
Usernames can have spaces and other nasties, so wrap it in double quotes to protect against that.


Code: [Select]
"%APPDATA%\IMVU"

DaveLembke

    Topic Starter


    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: %appdata% use within batch help
« Reply #10 on: June 08, 2016, 01:14:04 PM »
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.

 8)