Search code examples
vbscriptpathmovefile

VBS move files from download


how to move a file from C:\Users\username\Downloads is there a variable for username so that if it is on someone else his computer that it also works and that you don't need to chance the code. Because I can't acces the username so I can't move any files from the downlaods folder to an other folder. I look in windows command but there was no answer I have looked on the internet but there are more people with the same problem and also have no good answers. After 2 weeks I still do not know to path to the downloads folder with vbs. Any suggestions


Solution

  • There is but you shouldn't be using it. Environmental variables aren't for programs.

    There are a number of standard folders that are used frequently by applications, but may not have the same name or location on any given system. For example, the system folder may be "C:\Windows" on one system and "C:\Winnt" on another. The values in this enumeration are equivalent to the CSIDL values used in C++ applications. They provide a unique system-independent way for applications to identify special folders. They supersede the use of environment variables for this purpose.

    https://learn.microsoft.com/en-us/windows/win32/api/shldisp/ne-shldisp-shellspecialfolderconstants

    and to use

        set objShell = CreateObject("shell.application")
        set objFolder = objShell.NameSpace("C:\\")
    

    https://learn.microsoft.com/en-us/windows/win32/shell/shell-namespace