Solved

Wait Until Shell Finishes

Posted on 2013-01-12
3
827 Views
Last Modified: 2013-05-03
I am trying to retrieve data about the network adapter into Access, to do this I first need to create a file with data generated by the ipconfig command

Shell "cmd /c ipconfig /all >C:\dev\ip.txt"

I then read the ip.txt file into MS Access and extract the data I need (the pysical ethernet address) The problem is that the program does not wait long enough for the shell command to create the file and it then generates an error as the file has not yet been created. If I run the program again without deleting the file ip.txt it all works fine.

Any suggestions on how to make the program wait until the file has been created would be appreciated.

John

Background
The reason I am doing this is to ensure that the program can only be run on a designated computer. There may be easier ways than using the physical address of the network adapter. Any suggestions as to alternative ways of achieving this would be good.
0
Comment
Question by:jhswinson
3 Comments
 
LVL 39

Expert Comment

by:als315
ID: 38770078
May be will be enough to get, for example, MAC address:
http://www.ozgrid.com/forum/showthread.php?t=152338
In sample not declared variable GetNetworkConnectionMACAddress
Add line
Dim GetNetworkConnectionMACAddress As String
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 38770094
0
 
LVL 30

Expert Comment

by:hnasr
ID: 38770127
Try this:
Form1:
Private Sub Command2_Click()
    DoCmd.OpenForm "Form2", acNormal, , , , acDialog
    MsgBox ("BACK FROM DIALOG") ' this will wait untill you close Form2
    ' add your code to read the text file here.
End Sub

Form2:
Private Sub Command2_Click()
     Shell "cmd /c ipconfig /all >D:\ip.txt"
     ' you may use timer event to check for the existance of text file.
     'then dispose of Form2 to resume code in Form1
Exit Sub
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

757 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

20 Experts available now in Live!

Get 1:1 Help Now