2017-10-04 78 views
0

我可以列出所有已發佈的應用程序,這很有效,但是當嘗試獲取根應用程序文件夾時,我得到一個無效的過程調用。有誰知道我在這裏做錯了嗎?(傳統)MFCOM VBScript獲取無效的過程調用

Dim theFarm,rootAppFolder 
Set oWSHShell = CreateObject("Wscript.Shell") 
Set oWSHNetwork = CreateObject("WScript.Network") 
Set oWSHProcEnv = oWSHSHELL.Environment("PROCESS") 

      'Create MetaFrameFarm object 
      Set theFarm = CreateObject("MetaFrameCOM.MetaFrameFarm") 
       if Err.Number <> 0 Then 
       WScript.Echo "Can't create MetaFrameFarm object" 
       WScript.Echo "(" & Err.Number & ") " & Err.Description 
       WScript.Echo "" 
       WScript.Quit Err.Number 
       End if 


      'Initialize the farm object. 
      theFarm.Initialize 1 

      If Err.Number <> 0 Then 
       WScript.Echo "Can't Initialize MetaFrameFarm object" 
       WScript.Echo "(" & Err.Number & ") " & Err.Description 
       WScript.Echo "" 
       WScript.Quit Err.Number 
       End if 

Set rootAppFolder = theFarm.GetRootFolder(MetaFrameAppFolder) 'error on this line here 
Set appFolder = rootAppFolder.GetSubFolder("A_USA") 
Set folder = appFolder.AppFolder 

For each app in folder.Applications 

    app.LoadData(0) 
    WScript.Echo app.AppName 

Next 

回答

1

使用Option Explicit來避免失誤,如未初始化的MetaFrameAppFolder

+0

顯式選項是什麼。出於某種原因,當我把數字12放在那裏而不是MetaFrameAppFolder時,它就起作用了。現在我意識到應該將其設置爲一個常量。 –

相關問題