Results 1 to 6 of 6

Thread: Shell command error

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Posts
    259

    Shell command error

    i get a syntax error with the following shell command

    Code:
    Shell Environ$("UserProfile") & "\myinfo.bat"  Environ$("UserProfile") & "\outfile.txt",vbHide
    i know its just a comma or a quotes needed but i cant figure it out.

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Shell command error

    You didn't concatenate the string at the begining of the second call to Environ.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Posts
    259

    Re: Shell command error

    im still missing it. what do i need to do?

  4. #4
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Shell command error

    ...myinfo.bat" Environ$("Use...

    Those are not connected, you are missing the string concatenation: &

    ...myinfo.bat " & Environ$("Use...

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Shell command error

    im still missing it. what do i need to do?
    Shell Environ$("UserProfile") & "\myinfo.bat " & Environ$("UserProfile") & "\outfile.txt",vbHide

    Environ$("UserProfile")
    if the returned value from environ
    or the filename can contain space the path\filename must be enclosed in quotes

    Shell """" & Environ$("UserProfile") & "\myinfo.bat"" """ & Environ$("UserProfile") & "\outfile.txt""",vbHide
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Shell command error

    I was hoping to point him towards solving it himself, but ok.

    Using Chr(34) might be easier for him. I too sometimes get confused when the quotes pile up like that.

    Code:
    Shell Chr(34) & Environ$("UserProfile") & "\myinfo.bat" & Chr(34) & " " & Chr(34) & Environ$("UserProfile") & "\outfile.txt" & Chr(34),vbHide

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width