
Visit our shop for nerds in control lifestyle products.
- PC reliability?
- Windows, real time
- PID loops
- PCs vs. PLCs
- Replacing people
- MS 'monopoly'?
- Software quality
- Where do we go from here?
- Why pay?
-- The Grateful Dead
www.control.com/rss
i have a problem. i can't run the DOS commands in VB programs. Please help me.
what is the command in VB to run DOS commands?
and if you can, learn that.
TanQ!!!!!!!!!!!! :D
for 7.0 (.net) there are two ways. I believe shellex or shellexecute is one and the other is in threading. you'll have to search around, but it's out there I know 'cause I did it before. The threading one lets your program watch the commandline output of the other program and interact with it, whereas the shellex one only starts the other prog.
i think it is like ---------------------------> shell (ren abc.zip abc.doc)
get more information about how to use, read book for VB.
Regards,
Shailesh C Patel
FDC - Control Systems And Instrumentation
Reliance Engineering Associates(P) Ltd.
Jamnagar Refinery Complex
Jamnagar,
India
Ph:-0288-3011683
its under VBResources. you just change the bit where it says "WinWord" or whatever for your command.
Drogo
Shell(pathname[,windowstyle])
Robert Scott
Real-Time Specialties
Embedded Systems Consulting
Dude all you have 2 do 2 run CMD is type
Shell ("cmd.exe")
and pop! it will come right up
So the line would read Shell ("batchfile.bat")
Solution Provided,, Insoftdevelopment
I can throw Down a Complete Example if needed.
Many thanks for your help in advance.
jasmine
At run time, use shell or shellexecute to open and run the batch file.
for more info, visit my site @:
xigmasystems.bravehost.com
'=====================================
Dim sYourCommand as String
sYourCommand = "\\networkfolder\project\testfile.txt"
Shell "cmd /c " & sYourCommand, vbHide
'=====================================
This will open up a Command Prompt, execute the string that follows the /c, & remains hidden the entire time. All you see is the desired effect of the command. FYI, once the command is executed to completion, the command prompt will terminate from memory (but you shouldn't actually see the command prompt anyway cuz it's hidden).
Dim sYourCommand As String
ChDir Dir1 'since Dir1 is the current directory
sYourCommand = "dir " & Dir1 & "> " & Dir1 & "\index.txt"
Shell "cmd /c " & sYourCommand, vbHide
lRet = Shell("cmd /c move /y c:\Oldlocation.doc d:\newlocation.doc",vbHide)
the /c tells the cmd window to execute the string following. The /y on the move surpresses messages
visit www.planetsourcecode.com, this site will help you about visual basic.
I was looking for a snippet code that could help me type DOS commands into VB, I wrote a simple code to perform such task anyway:
If ExecuteDOSCommand("mkdir c:\my_test_folder") Then
MsgBox "it worked..."
End If
End Sub
Function ExecuteDOSCommand(ByVal command As String) As Boolean
On Error Resume Next
'require microsoft scripting runtime reference
Dim Fso As New FileSystemObject
Dim oText As TextStream
Dim BatFile As String
BatFile = App.Path & "\vbcommand.bat"
Fso.CreateTextFile BatFile, True
Set oText = Fso.OpenTextFile(BatFile, ForWriting)
oText.WriteLine command
oText.Close
Set oText = Nothing
Set Fso = Nothing
ExecuteDOSCommand = Shell("""" & BatFile & """") > 0
End Function
=======================
Private Sub Command1_Click()
P$ = Environ$("WINDIR") + "\system32\cmd.exe /c mkdir c:\mynewdir"
Print P$
If Shell(P$) > 0 Then
Print "greater"
ChDir "c:\mynewdir"
Else
Print "less or equal"
End If
End Sub
=============================
note "c:\mynewdir" could be "C:\home\"+username$(j) to create home directories for all users or whatever
- Portable computing: Operators can be mobile with rugged HMI
- Whitepaper: Small form factor HMIs evolve
- Remote control: Get behind firewalls—securely
- Security: Yokogawa partners to add industrial firewall
- Performance intelligence: SmartSignal, General Physics deal focuses on expertise exchange
- ABB update: User conference, exhibition, flow, SCADA, wireless
- Interoperability: OPC for embedded applications
- Learning: Profibus, FDT seminars; FDT testing
- Fun engineering: FIRST Robotics Championship
- Rockwell to acquire Incuity Software; research shows how it could help
Users of this site are benefiting from open source technologies, including PHP, PostgreSQL and Apache. Be happy.
Patronize our advertisers!



