?
Solved

Shell String

Posted on 2002-04-07
9
Medium Priority
?
302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 6

Expert Comment

by:xSinbad
ID: 6924236
Try ading the full path to rename.exe
0
 
LVL 3

Author Comment

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

Bob Scriver
0
 
LVL 3

Author Comment

by:Bob Scriver
ID: 6924278
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 9

Expert Comment

by:ornicar
ID: 6924333
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
 
LVL 3

Author Comment

by:Bob Scriver
ID: 6924375
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 200 total points
ID: 6924378
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
ID: 6924468
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
ID: 6924469
Your comment is exactly what was needed to finish off my application.  Thanks

Bob scriver
0
 
LVL 9

Expert Comment

by:ornicar
ID: 6924822
You are welcome
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

752 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