Solved

Shell String

Posted on 2002-04-07
9
294 Views
Last Modified: 2012-06-22
I am attempting to poll through a number of network mappings and perform copy and rename command line executions from within a Shell statement.  I can't seem to get the syntax correct.  Keep getting a Cannot fine the file error.

Dim vShellString as string
Dim x as variant

vShellString = "Rename c:\access\filename.mdb filename-final.mdb"
x = Shell(vShellString)

If I execute the exact characters in a MSDOS i.e. Rename . . . .mdb  as stated above it works fine.  But, by putting it into a string there must be a syntax problem with quotes, etc. that it does not recognize the path that is being described.  I have tried cancatenating chr(34) on both ends of the string, around the actual path only, chr(39) around the path only, etc.

Can't seem to get it to work.  

Ideas experts.

Bob Scriver
0
Comment
Question by:Bob Scriver
  • 5
  • 3
9 Comments
 
LVL 6

Expert Comment

by:xSinbad
Comment Utility
Try ading the full path to rename.exe
0
 
LVL 3

Author Comment

by:Bob Scriver
Comment Utility
xSinBad:
I don't understand what you mean by your comment.  Please elaborate.

Bob Scriver
0
 
LVL 3

Author Comment

by:Bob Scriver
Comment Utility
I have resolved this question myself.  The shell statement requires a reference to the command file ( i.e. cmd /c ) within the shell string.

It should look like this:

vShellString = "cmd /c Rename c:\access\filename.mdb filename-final.mdb"

The shell statement must reference the command file to know what to do with the Reserved Command word Rename, Copy, etc.  

I will ask CS to reduce the points to 0 but I will leave this question active for others to benefit from this finding.

Bob Scriver
0
 
LVL 9

Expert Comment

by:ornicar
Comment Utility
Just note that you can rename a file without invoking the DOS command. Simply:

Name [SourceFile], [DestFile]

Will do the job fine with no splashing DOS window.

You can even trap the error:

On Error Resume Next

Name [SourceFile], [DestFile]
if err <> 0 then
    msgbox "Error on renaming file: ", Error$
endif
On Error Goto 0
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 3

Author Comment

by:Bob Scriver
Comment Utility
Ornicar:

Please be more specific because I can only find Name as a property and not in the command type format that you suggest.

Bob
0
 
LVL 9

Accepted Solution

by:
ornicar earned 50 total points
Comment Utility
Name is also a file command, The exact command is:

NAME "c:\access\filename.mdb" AS "c:\access\filename-final.mdb"

I forgott the AS. My fault.
0
 
LVL 3

Author Comment

by:Bob Scriver
Comment Utility
Ornicar:
Thanks for the follow-up to this question.  Although the original question had to do with the format of the Shell string you have given me a better way of manipulating the files with the Name command.  Also, the FileCopy and Kill commands give me everything that I need.  so I am going to award you the points for this question and with draw my request to CS to reduce the points to 0.  

Bob Scriver
0
 
LVL 3

Author Comment

by:Bob Scriver
Comment Utility
Your comment is exactly what was needed to finish off my application.  Thanks

Bob scriver
0
 
LVL 9

Expert Comment

by:ornicar
Comment Utility
You are welcome
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now