|
-
Aug 13th, 2004, 09:57 PM
#1
Thread Starter
New Member
How do I access a local file?
I need to access a file that is stored on a local machine.
What is the code to say open "C:\RunThis.bat" when clicking cmdRun button? Forgive me if this is a simple question, but then it shouldnt take too long to answer.
-
Aug 13th, 2004, 10:01 PM
#2
Thread Starter
New Member
Also I might add another thing...
Is there a way to copy a local file to say make a backup?
For instance click cmdBackup and "C:\Runthis.bat" creates "C:\RunthisBackup.bat"
-
Aug 13th, 2004, 11:15 PM
#3
use the SHELL command to execute a batch file, and SHELLEXECUTE to open the file. SHELL (filename,0) will hide the window, 1 will run it with normal focus.
using FileSystemObject.CopyFile source,destination,overwrite
will copy a file. overwrite can be True or False.
Don't know if you are using a FSO, though.
there is also FileCopy source, destination
if you aren't
Hope this helps.
Last edited by dglienna; Aug 13th, 2004 at 11:19 PM.
-
Aug 13th, 2004, 11:20 PM
#4
You can use the Shell command which opens a program. To open a text file in notepad, for example:
VB Code:
Shell "notepad ""C:\testfile.txt"""
ShellExecute is an API function (one which you must set a reference too) which will run a file in the default program.
VB Code:
'Example
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
ShellExecute 0, "Open", "C:\RunThis.bat", "", "C:\", 1
That will run the bat file in the default program, which is, Command Prompt. Other examples are HTML files in the defualt browser, IE, Netscape, or others..
Phreak
Visual Studio 6, Visual Studio.NET 2005, MASM
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
|