12-18-2019 09:54 AM
Hi all,
I wrote a "DIAdem welcome pack" for users of my software, that among other things automatically registers and saves user commands. Some of the users of my scripts are a bit inconsistent on where they put the "welcome pack" source files, and they end up having multiple copies of the same user commands in their DIAdem installation.
I would like to remove all user commands upon running the "welcome pack", such that afterwards they only have the new user commands. I tried using ScriptCmdReset as suggested here, but since the desktop file is saved (using DeskSave) it doesn't have any effect. I cannot use ScriptCmdRemove because I don't know what path the users used in their previous installation.
Do you have any ideas?
12-19-2019 05:07 AM
It would be helpful to know more about where, when, and how you execute ScriptCmdAdd().
Is the script filename that contains the user commands known? If so, then perhaps the solution is to identify all instances of that file and delete them. Try adapting the function below for your needs. The function below searches in DIAdem folders for example files that come with the installation. You should expand the folders search to those you think the user may have the script file you wish to delete. Consider:
GetEnv("USERPROFiLE")) or SHGetFolderPath(&H0005)
Function sFilePathDIAdemExample(ByVal sFilename)
  'Returns the full absolute file/path for the location of the DIAdem
  'example (TDM/TDMS) file sFilename.  Looks in the usual places.
  'Returns "" if the file cannot be found.
  'v20191119
  sFilePathDIAdemExample = ""
  Dim arrFilePaths, sFilePath, sFolder: ReDim arrFolders(2): arrFolders(0) = ProgramDrv: arrFolders(1) = CommonDocumentsPath: arrFolders(2) = GetEnv("PUBLIC")
  For Each sFolder In arrFolders
    arrFilePaths = DirListGet(sFolder,sFilename,"Date/Time","FullFilenamesRecursive")
    If IsArray(arrFilePaths) Then
      For Each sFilePath In arrFilePaths
        If InStr(1,sFilePath,"Libr",vbTextCompare) = 0 Then sFilePathDIAdemExample = sFilePath: Exit For
      Next
    End If
    If Len(sFilePathDIAdemExample) > 0 Then Exit For
  Next
  If IsArray(arrFilePaths) Then Call Erase(arrFilePaths)
  If IsArray(arrFolders) Then Call Erase(arrFolders)
End Function  'sFilePathDIAdemExample()
12-22-2019 11:26 AM
Hi markwkiehl,
Thank you for your reply. The user commands are files incuded in the DIAdem welcome pack that installs them. The problem arises because the users store the full pack (installer script and user command files) in random locations when downloaded, and again in a different location after re-downloading.
I could adapt your solution to scan the C: drive for the pack folder, but I was looking for something more elegant 🙂
Cheers!