Forum Discussion

hallan_cits's avatar
hallan_cits
New Contributor
11 years ago

Open file in Desktop


Hello, the question is simple. 


I would like to open an audio file that is on the desktop. 


How would I do this? 


 


I searched the internet and not found. When searching for something using the 'aqFileSystem' not found anything relating to open a file.



thanks

4 Replies

  • This will open the file in the default audio player:

    // JScript

    Sys.OleObject("WScript.Shell").Run("C:\\Users\\Helen\\Desktop\\File.mp3");


    If the file path has spaces, put extra quotes around it:

    // JScript

    Sys.OleObject("WScript.Shell").Run("\"C:\\Users\\Helen\\Desktop\\My File.mp3\"");

    // or

    Sys.OleObject("WScript.Shell").Run(aqString.Quote("C:\\Users\\Helen\\Desktop\\My File.mp3"));


    If you don't want to hardcode the Desktop folder path, you can get it programmatically:

    // JScript

    var oShell = Sys.OleObject("WScript.Shell");

    var strDesktop = oShell.SpecialFolders("Desktop");

    var strFileName = aqFileSystem.IncludeTrailingBackSlash(strDesktop) + "My File.mp3";



    oShell.Run(aqString.Quote(strFileName));




    More info: Run Method (Windows Script Host)
  • Hi,

     


    What do you mean by "open an audio file"? Do you want to play it? Or do you want to read its source?


     

  • Marsha_R's avatar
    Marsha_R
    Icon for Champion Level 3 rankChampion Level 3
    Once you locate the object, you should be able to either double click on it or use right click and then select Open from the menu.



    http://support.smartbear.com/viewarticle/58891/





    If you just want to get the thing started and don't care about the icon, you could add it as a tested app and then use Run Tested App.