Results 1 to 2 of 2
  1. #1
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480

    VBscript. combining Getfile with Oshell.Environment

    I'm trying to modify an old vbs file, I'm running into an issue that has me stumped.

    Code:
    Dim oShell, oFS, oLocFile, oShortcut, oMacFolder, oEnv, oSig
    ''''''
    Set oFS = CreateObject("Scripting.FileSystemObject")
    Set oShell = WScript.CreateObject ("WScript.Shell")
    Set oEnv = oShell.Environment("Process")
    
    
    Set oLocScript = oFS.GetFile (oEnv("userprofile") & "\My Documents\ProgramName\Launchit.vbs")
    Set oLocFile = oFS.GetFile (oEnv("userprofile") & "\My Documents\ProgramName\TerminalSessionFile.rsf")
    
    
    oShell.run oLocFile


    So this is a trimmed down version, but basically I want to identify oLocScript and oLocFile as local files, but I have to instruct them to use the user profile. If I replace that and just dump everything into a common C drive folder it works fine. But due to environment restrictions it has to go into my docs. Also, I'm not even sure if oShell.run is going to know how to handle opening this .rsf file.


    When I run the code it tells me that File can't be found on Set oLocScript.




    I know this isn't a VBscript forum, but any help is always appreciated.

  2. #2
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    To be sure you get the correct folder, how about using oShell.SpecialFolders("MyDocuments") instead of building it OS dependent.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. vbscript open access db and execute sub
    By Auto in forum Programming
    Replies: 1
    Last Post: 04-22-2015, 01:29 PM
  2. Replies: 4
    Last Post: 10-03-2014, 12:27 PM
  3. Replies: 2
    Last Post: 09-15-2014, 01:51 PM
  4. Replies: 14
    Last Post: 07-22-2013, 12:39 PM
  5. Replies: 2
    Last Post: 06-20-2011, 09:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums