在vb里应该如何用命令行???

wuhu 2002-12-29 07:43:22
我想在vb中调用net命令~~不知道这样可以吗?
dim ip as string
dim user as string
dim passwd as string

shell("net.exe use r: //& ip &/d$ "& passwd &" /user:"% user %"")

这样可以吗?
...全文
25 点赞 收藏 14
写回复
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuhu 2002-12-31
那应该怎么才对啊?
回复
jacklee19822001 2002-12-30
命令是有点错误,里面的"太多了,看起来很累
回复
wuhu 2002-12-30
好象~~~程序就通过了~~不过windows的命令行却说语法有错误?
究竟是什么地方出错了吖?
回复
suntt 2002-12-30
呵呵
回复
zyl910 2002-12-30
加上ShellExecute的申明:
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
回复
wuhu 2002-12-29
andy 大大的我改成
ShellExecute Me.hWnd, "open", "net.exe", "use r: //& ip &/d$ " & passwd & " /user:" & user & "", "", 1
~~再运行~~系统却提示说:子程序或函数未定义~为什么啊?
回复
wuhu 2002-12-29
两位大大~~我着你们说的方法去做~~
可是好象不行吖 ~~~
910的好象没有效果~~
而andy好象语法有错误~~
假设~我要把192.168.0.1的机的D盘映射过来`~应该怎么做啊?
回复
fling_boy 2002-12-29
ShellExecute me.hwnd,"open","net.exe","use r: //& ip &/d$ "& passwd &" /user:"% user %","",1
回复
zyl910 2002-12-29
Call Shell("net.exe use r: //& ip &/d$ " & passwd & " /user:" & user & "")
回复
wuhu 2002-12-29
up~~~^0^
回复
wuhu 2002-12-29
谢谢~~~
那net use 的命令应该如何实现啊?
怎么老是说我缺少语句结束~
回复
xks 2002-12-29
Shell """" & "1.exe" & """ " & "c:\1.txt", vbNormalFocus
回复
leonnet 2002-12-29
up
回复
fling_boy 2002-12-29
http://expert.csdn.net/Expert/topic/1309/1309035.xml?temp=.5095178


ShellExecute

VB声明
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
说明
查找与指定文件关联在一起的程序的文件名
返回值
Long,非零表示成功,零表示失败。会设置GetLastError
参数表
参数 类型及说明
hwnd Long,指定一个窗口的句柄,有时候,windows程序有必要在创建自己的主窗口前显示一个消息框
lpOperation String,指定字串“open”来打开lpFlie文档,或指定“Print”来打印它
lpFile String,想用关联程序打印或打开一个程序名或文件名
lpParameters String,如lpszFlie是可执行文件,则这个字串包含传递给执行程序的参数
lpDirectory String,想使用的完整路径
nShowCmd Long,定义了如何显示启动程序的常数值。参考ShowWindow函数的nCmdShow参数


ShellExecute me.hwnd,"open","1.exe","c:\1.txt","",1

回复
发动态
发帖子
VB基础类
创建于2007-09-28

7451

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告