Question

Can anyone help me with cracking this nut?

I have a folder in %localappdata% that is partly random that I need to move a file into.

%localappdata%\acroprint\TQP4_{random string of letters}\4.1.15.25435\

dim filesys, oShell

Set oShell = CreateObject("WScript.Shell")
strHomeFolder = oShell.ExpandEnvironmentStrings("%LOCALAPPDATA%")

set filesys=CreateObject("Scripting.FileSystemObject") 
If filesys.FileExists("\\tstcfile\public\tqp41_15\user.config") Then 
   filesys.CopyFile "\\tstcfile\public\tqp41_15\user.config", strHomeFolder & "\Acroprint\TQP4_{random string of letters}\4.1.15.25435\", true 
End If

So far, this is the closest I can get the script to work. My issue is with the random string of numbers and letters that is unique on each desktop. I know I cant use an * in the destination. Does anyone know a workaround?

Thanks Chris

Était-ce utile?

La solution

Something like this should work:

srcFile = "\\tstcfile\public\tqp41_15\user.config"
parentFolder = filesys.BuildPath(strHomeFolder, "acroprint")

For Each sf In filesys.GetFolder(parentFolder).SubFolders
  If UCase(Left(sf.Name, 5)) = "TQP4_" Then
    filesys.CopyFile srcFile, filesys.BuildPath(sf.Path, "4.1.15.23435\"), True
    Exit For
  End If
Next
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top