Results 1 to 5 of 5
  1. #1
    AccessPower's Avatar
    AccessPower is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    165

    UNC Path Error when running Shell

    Hey Everyone,



    So I'm trying to run a script from Access, but I keep getting an error. The issue is that all user accounts on my network are migrated to a server, so cmd starts in a UNC path, which is apparently not supported according to the error. I am trying to use this code:

    Code:
    Dim sPath As String
    sPath = "cmd / k S:\Workgroups\Information Resources\Validation\"
    sCommand = "RunValidationTest.wsf RemoteValidation"
    
    
    Call Shell(Environ$("COMSPEC") & " /k " & """ & sPath & """ & sCommand, vbNormalFocus)
    This I managed to get to run without the UNC error, but I can tell it isn't working because the /k switch isn't working (the window closes) and no email is sent.

    Any ideas as to how to go about this? I am stuck at this point.

    Edit:

    I tried a few other things. I tried to get Application.followhyperlink to run a cmd file that references the wsf file. That didn't work either. Just opens/closes. I don't see anything, and when I try to pipe the output to a txtfile to see if there is an error, it's blank. lol

    Thanks!

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    There is also ShellExecute.

  3. #3
    AccessPower's Avatar
    AccessPower is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    165
    It still isn't working. I think i may just have to recode the vbs in VBA.

  4. #4
    AccessPower's Avatar
    AccessPower is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    165
    So for those of you looking for an answer for this, what I did was have the script file check for a pc name inside of a text file in the temp folder (if found, it uses the pc name as a variable and then deleted the file when it's done). I had access create the file and write the pc name to it. Then I had access shell open the executable. It works like a charm.

  5. #5
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    Thanks for sharing your solution! I was going to dive into my notes about UNC paths in command files, but I'm not sure what sCommand is in your code. Then I suspected the spaces in your path needed hard coded quotes around it (inside the quotes used to assign the string to the variable) so that it becomes
    "S:\Workgroups\Information Resources\Validation" and not
    S:\Workgroups\Information Resources\Validation\
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 6
    Last Post: 05-27-2014, 05:41 AM
  2. Replies: 3
    Last Post: 11-24-2012, 08:56 AM
  3. Running a shell command from a stored procedure.
    By sstrauss87 in forum SQL Server
    Replies: 3
    Last Post: 03-01-2012, 04:39 PM
  4. wait and shell
    By maxbre in forum Programming
    Replies: 19
    Last Post: 11-03-2011, 11:10 AM
  5. Using Shell in VBA
    By ghutche in forum Programming
    Replies: 7
    Last Post: 03-17-2011, 10:13 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