Solved

switch to DOS mode

Posted on 2002-06-02
6
182 Views
Last Modified: 2010-05-02
what is the easy way to switch to DOS mode from VB , I want to
copy a file from one directory to floppy disk  as zipfile .
0
Comment
Question by:jeddha
6 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7049624
In Windows 9x, Me:
Shell "command.com"

In Windows NT, 2000, XP:
Shell "cmd.exe"

Anthony
0
 

Accepted Solution

by:
dhavaljariwala earned 50 total points
ID: 7050507
' you can do this by sending keystrokes to dos programs running.

Option Explicit

Private mvarDestination As Long 'local copy
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_SHIFT = &H10

Private Declare Function OemKeyScan Lib "user32" (ByVal wsOemchar As Integer) As Long
Private Declare Function CharToOem Lib "user32" Alias "CharToOemA" (ByVal lpszSrc As String, ByVal lpszDst As String) As Long
Private Declare Function VkKeyScan Lib "user32" Alias "VkKeyScanA" (ByVal cChar As Byte) As Integer
Private Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Private Sub SendAKey(ByVal sKeys As String)

   Dim vk            As Integer
   Dim nShiftScan    As Integer
   Dim nScan         As Integer
   Dim sOemchar      As String
   Dim nShiftKey     As Integer
   
   ' *** Get the virtual key code for this character
   vk = VkKeyScan(Asc(sKeys)) And &HFF
   ' *** See if shift key needs to be pressed
   nShiftKey = VkKeyScan(Asc(sKeys)) And 256
   sOemchar = " " ' 2 character buffer
   ' *** Get the OEM character - preinitialize the buffer
   CharToOem Left$(sKeys, 1), sOemchar
   ' *** Get the nScan code for this key
   nScan = OemKeyScan(Asc(sOemchar)) And &HFF
   ' *** Send the key down

   If nShiftKey = 256 Then
      ' *** if shift key needs to be pressed
      nShiftScan = MapVirtualKey(VK_SHIFT, 0)
      ' *** press down the shift key
      keybd_event VK_SHIFT, nShiftScan, 0, 0
   End If

   ' *** press key to be sent
   keybd_event vk, nScan, 0, 0
   ' *** Send the key up

   If nShiftKey = 256 Then
      ' *** keyup for shift key
      keybd_event VK_SHIFT, nShiftScan, KEYEVENTF_KEYUP, 0
   End If

   ' ***keyup for key sent
   keybd_event vk, nScan, KEYEVENTF_KEYUP, 0
   
End Sub

Public Sub SendKeys(ByVal sKeys As String)

   Dim X          As Integer
   
   ' *** loop thru string to send one key at a time
   For X = 1 To Len(sKeys)
      ' ***activate target application
      AppActivate (mvarDestination)
      ' ***send one key to target
      SendAKey Mid$(sKeys, X, 1)
   Next

End Sub

Public Property Let Destination(ByVal vData As Long)
   'used when assigning a value to the property, on the left si
   '     de of an assignment.
   
   ' ***Syntax: X.Destination = 5
   mvarDestination = vData
   
End Property

Public Property Get Destination() As Long
   
   'used when retrieving value of a property, on the right side
   '      of an assignment.
   ' ***Syntax: Debug.Print X.Destination
   Destination = mvarDestination
   
End Property
0
 

Author Comment

by:jeddha
ID: 7053604
I want to copy a file from one loaction to another
  shell "command.com /c " & "copy c:\test.txt a:\"
here its not working
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7053827
That is odd.  It worked fine for me.  Did you put the disk in A drive?

Anthony
0
 

Expert Comment

by:jonnyfunfun
ID: 7054018
Why don't you just use a FileSystemObject to copy the file?  It would probably be a lot easier.

Just add a reference to the Scripting Library in your project and use the following code:


Dim fso
Set fso=CreateObject("Scripting.FileSystemObject")
fso.CopyFile filesource, filedestination, overwrite


Just replace the filesource with your source file and the filedestination with your destination file.  The overwrite is an optional boolean which will force the file to be copied if it set to true (by default it is False).  I think the above code is correct.
0
 

Author Comment

by:jeddha
ID: 7066407
I mean DOS mode printing is very fast compared to others
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)

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

821 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