Solved

Wait Until Shell Finishes

Posted on 2013-01-12
3
861 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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reference theme colors in VBA 4 23
Filter cbo on datasheet - 11 30
Delete QueryDef IF it Exists: Access VBA 5 28
unable to create table-based data macro in MS ACCESS 2013 11 22
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

816 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

8 Experts available now in Live!

Get 1:1 Help Now