locked
How to use VBScript to run virtualized office 2010 RRS feed

  • Question

  • Hi,

    Can anyone please help with the following issue.

    I have this vbscript code that is able to launch Microsoft Office Word installed on a local machine.

    dim objWord
    Set objWord = CreateObject("Word.Application")
    objWord.Visible = True
    Set objDoc = objWord.Documents.Add()

    However the code is unable to launch Virtualized Office 2010 WORD as in APP-V environment. I am able to execute the following command in the command prompt to launch the virtualized office word 2010 successfully:

    C:\>SFTTRAY /EXE "C:\Documents and Settings\asens\Desktop\APP-v TOOLS\launch

    word.vbs" /LAUNCH "Microsoft Word 2010 14.0.4755.1000"

    I need help on how to put this command in the vbscript to make it launch the virtualized office 2010.

    Your reply would be highly appreciated.

    Thanks.


    ka
    Friday, December 10, 2010 9:16 AM

Answers

  • try changing the command to

    SFTTRAY /EXE WSCRIPT <PATH TO SCRIPT> /LAUNCH "Application Name Version"

    You could use CSCRIPT in place of WSCRIPT but you may see a command window open briefly.

    However, why use a VBscript to run a command, can't you just run the command directly?

    • Proposed as answer by znack Friday, December 10, 2010 2:41 PM
    • Marked as answer by Kasenso Friday, December 10, 2010 3:56 PM
    Friday, December 10, 2010 11:54 AM
    Moderator

All replies

  • Hello,

    Doesn't that command-line work in script..?
    /Znack
    Friday, December 10, 2010 10:16 AM
  • Hi,

    The command actually works at the command prompt. It is able to open the virtualized Office 2010 application in APP-V. What I actually need is a vbscript that can run on the local machine to execute this (that is SFTTRAY /EXE "C:\Documents and Settings\asens\Desktop\APP-v TOOLS\launch word.vbs" /LAUNCH "Microsoft Word 2010 14.0.4755.1000") command in order to open the virtualized application in APP-V.

    I have tried the following script but it tells me that the specified application does not exist. 

    set objShell = wscript.createobject("wscript.shell")
    M = "SFTTRAY /EXE"
    P = """C:\Documents and Settings\asens\Desktop\App-v TOOLS\launch word.vbs"""
    L = " /Launch "
    W = """Microsoft Word 2010 14.0.4755.1000"""
    cmd = M+P+L+W
    objShell.run cmd

    But when I run SFTTRAY /EXE "C:\Documents and Settings\asens\Desktop\APP-v TOOLS\launch word.vbs" /LAUNCH "Microsoft Word 2010 14.0.4755.1000" at the command prompt, it is able to open the application.

    Any help?


    ka
    Friday, December 10, 2010 11:09 AM
  • try changing the command to

    SFTTRAY /EXE WSCRIPT <PATH TO SCRIPT> /LAUNCH "Application Name Version"

    You could use CSCRIPT in place of WSCRIPT but you may see a command window open briefly.

    However, why use a VBscript to run a command, can't you just run the command directly?

    • Proposed as answer by znack Friday, December 10, 2010 2:41 PM
    • Marked as answer by Kasenso Friday, December 10, 2010 3:56 PM
    Friday, December 10, 2010 11:54 AM
    Moderator
  • Hi,

    Thanks once again. Your help has actually saved us alot.

    I have managed to get it working absolutlely perfect. We actually needed it for our website to be able to launch the virtualized office application when using a particular application.

    Sub Launch
     If cboFiles.selectedIndex = -1 Then
      MsgBox("Please select a template")
      Exit Sub
     End If
     
     Dim strFile
     strFile = "\\erac\users\Common\Corp\" & cboFolders.value & "\" & cboFiles.value
     
     fileExtension = Mid(cboFiles.value,InStr(1,cboFiles.value,".")+1)
     If fileExtension = "dot" Then

     Dim objShell
     Set objShell = CreateObject("WScript.Shell")
    ' msgbox "sfttray /launch ""Microsoft Word 2010""" & " """ & strfile & """"
     objShell.run "sfttray /launch ""Microsoft Word 2010""" & " """ & strfile & """"


    ka
    Friday, December 10, 2010 1:08 PM
  • Old thread, but the answer to Aaron's question, "Can't you just run the command directly?", is that Automation offers the ability to run a VBA macro outside of an Office Application...but only when VBS is given access to Word.Application. With it, you can do most anything you could do with VBA from within the application. And that's pretty powerful stuff. Much more than you can do from the command line. But App-V appears not to afford us that luxury.

    OP has a use for it; I have a similar use, to overcome WS2008 R2 RDS RemoteApps' lack of support for user environment variables. If OP and I could use Automation, it would not matter what version of Word we used, or any of the details of how we virtualized Word. The script would Just Work(tm).

    I had a really elegant little VBS script written to handle a variety of Word launch tasks I'll need to offer my users in a RemoteApp + App-V environment. But without GetObject("Word.Application") and CreateObject(, "Word.Application"), the script will be an ongoing maintenance task.

    Aaron's workaround is probably about to make its debut in my script. And I'm glad there is at least a workaround--however deficient--or I'd be in big trouble! But Automation is an elegant way to handle Office scripting.

    And if anyone from MS's App-V team is reading this, it sure would be nice if offvirt.msi supported it.


    • Edited by JRV529088 Monday, October 31, 2011 4:18 AM
    Monday, October 31, 2011 4:18 AM