|
-
Jul 20th, 2010, 09:59 AM
#1
Thread Starter
Hyperactive Member
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.
-
Jul 20th, 2010, 10:01 AM
#2
Re: Shell command error
You didn't concatenate the string at the begining of the second call to Environ.
-
Jul 20th, 2010, 11:34 AM
#3
Thread Starter
Hyperactive Member
Re: Shell command error
im still missing it. what do i need to do?
-
Jul 20th, 2010, 12:04 PM
#4
Re: Shell command error
...myinfo.bat" Environ$("Use...
Those are not connected, you are missing the string concatenation: &
...myinfo.bat " & Environ$("Use...
-
Jul 20th, 2010, 04:41 PM
#5
Re: Shell command error
im still missing it. what do i need to do?
Shell Environ$("UserProfile") & "\myinfo.bat " & Environ$("UserProfile") & "\outfile.txt",vbHide
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
-
Jul 20th, 2010, 04:54 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|