Equivalent %username% for VB script

后端 未结 2 1045
太阳男子
太阳男子 2021-01-17 03:33

I am looking to delete OfficeFileCache folder from the current user\'s computer. Currently I have..

Option Explicit
Dim obj : Set obj =CreateObject (\"wscrip         


        
2条回答
  •  遇见更好的自我
    2021-01-17 04:03

    If you're using some path like

    C:\Users\%username%\AppData\Local\...
    

    This is better:

    %LocalAppData%\...
    

    So

    Fso.DeleteFolder Obj.ExpandEnvironmentStrings("%LocalAppData%\Microsoft\Office\16.0\OfficeFileCache")
    

    does it better, in case the user set their %UserProfile% to another directory.

提交回复
热议问题