cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
it-666
Level 3

Automation DeleteSubFolder DeleteShortcut issue

Hi,

im using the IS2015 automation Interface with vbs to automate some builds.

I have problems deleteting a folder and also deleting a shortcut in the start menu.


At the beginning my startmenu folder (System Configuration -> Shortcuts) structure looks like this:

Shortcuts -> [TaskBarFolder] -> [StartMenuFolder] -> ProgramMenuFolder -> ProgramMenuCompanyFolder -> ProgramMenuProductFolder -> NewShortcut1


I try to delete "NewShortcut1" and "ProgramMenuProductFolder ":

pProject.ISWiFeatures.Item("Hauptanwendung").ISWiComponents.Item("CMP_StartMenuShortcut").ISWiFolders.Item("[TaskBarFolder]").SubFolders("[StartMenuFolder]").SubFolders("[ProgramMenuFolder]").SubFolders("ProgramMenuCompanyFolder").SubFolders("ProgramMenuProductFolder").DeleteShortcut("NewShortcut1")

pProject.ISWiFeatures.Item("Hauptanwendung").ISWiComponents.Item("CMP_StartMenuShortcut").ISWiFolders.Item("[TaskBarFolder]").SubFolders("[StartMenuFolder]").SubFolders("[ProgramMenuFolder]").SubFolders("ProgramMenuCompanyFolder").DeleteSubFolder("ProgramMenuProductFolder")


But i always end up with a type missmatch error. What am i doing wrong?

Please help 🙂
Labels (1)
0 Kudos
(5) Replies
hidenori
Level 17

The syntax for the DeleteSubFolder and DeleteShortcut methods of the ISWiFolder automation interface are documented incorrectly. They actually take an ISWiFolder and ISWiShortcut object respectively as follows:

  • DeleteSubFolder (pSubFolderAs ISWiFolder ) As Long
  • DeleteShortcut (pShortcut As ISWiShortcut ) As Long


So your script should be changed like this:
[CODE]Set pFolder = pProject.ISWiFeatures.Item("Hauptanwendung").ISWiComponents.Item("CMP_StartMenuShortcut").ISWiFolders.Item("[TaskBarFolder]").SubFolders("[StartMenuFolder]").SubFolders("[ProgramMenuFolder]").SubFolders("ProgramMenuCompanyFolder").SubFolders("ProgramMenuProductFolder").

If pFolder Is Not Nothing Then
Set pShortcut = pFolder.ISWiShortcuts("NewShortcut1")
If pShortcut Is Not Nothing Then
pFolder.DeleteShortcut(pShortcut)
EndIf
EndIf[/CODE]

Hope that helps.
0 Kudos
it-666
Level 3

Thanks, for your reply.

I could delete the shortcut successfully with your code:


[CODE]Set pFolder = pProject.ISWiFeatures.Item("Hauptanwendung").ISWiComponents.Item("CMP_StartMenuShortcut").ISWiFolders.Item("[TaskBarFolder]").SubFolders("[StartMenuFolder]").SubFolders("[ProgramMenuFolder]").SubFolders("ProgramMenuCompanyFolder").SubFolders("ProgramMenuProductFolder")

If pFolder Is Not Nothing Then
Set pShortcut = pFolder.ISWiShortcuts("NewShortcut1")
If pShortcut Is Not Nothing Then
pFolder.DeleteShortcut(pShortcut)
EndIf
EndIf[/CODE]


But i could not delete a subfolder like this:


[CODE]Set pFolder = pProject.ISWiFeatures.Item("Hauptanwendung").ISWiComponents.Item("CMP_StartMenuShortcut").ISWiFolders.Item("[TaskBarFolder]").SubFolders("[StartMenuFolder]").SubFolders("[ProgramMenuFolder]").SubFolders("ProgramMenuCompanyFolder")

If pFolder Is Not Nothing Then
Set pSubFolder = pFolder.SubFolders.Item("ProgramMenuProductFolder")
If pSubFolder Is Not Nothing Then
pFolder.DeleteSubFolder(pSubFolder)
EndIf
EndIf
[/CODE]

I get the following error message:

ISWiAuto22: Invalid procedure call or argument
> ISWiAutomation.ISWiFolder.DeleteSubFolder
0 Kudos
hidenori
Level 17

There is a bug with the ISWiFolder.DeleteSubFolder method. It currently does not work with subfolders containing a uppercase letter in the key names. The key names have to be all lowercase for the method to work. So I filed the work order #IOJ-1764845 to address this issue for a future release.

To get it workaround, try manually changing the Key Name property of the ProgramMenuProductFolder folder to programmenuproductfolder in the IDE, and changing your script as follows:

If pFolder Is Not Nothing Then
Set pSubFolder = pFolder.SubFolders("programmenuproductfolder")
If pSubFolder Is Not Nothing Then
pFolder.DeleteSubFolder pSubFolder
EndIf
EndIf
0 Kudos
it-666
Level 3

Ok, now with all subfolder written in lowercase letters the method works fine. Thanks for that.


Is there a possibility to copy an existing shortcut one subfolder level up?

From:
Shortcuts -> [TaskBarFolder] -> [StartMenuFolder] -> ProgramMenuFolder -> ProgramMenuCompanyFolder -> ProgramMenuProductFolder -> NewShortcut1

To:
Shortcuts -> [TaskBarFolder] -> [StartMenuFolder] -> ProgramMenuFolder -> ProgramMenuCompanyFolder -> NewShortcut1


This way i doesn`t have to add a completly new one with all its properties...
0 Kudos
hidenori
Level 17

Although the Shortcuts view in the IDE includes the right-click shortcut menu options that lets you copy an existing shortcut and paste it into another folder, the automation interface currently does not support the same functionality. You need to create a new shortcut and copy all properties one by one. So I submitted the enhancement work order ISDEV-37851 to take into consideration for a future release.
0 Kudos