Dim p As new Process()
p.StartInfo.FileName = "cmd.exe"
p.StartInfo.UseShellExecute = False '关闭Shell的使用
p.StartInfo.RedirectStandardInput = True '重定向标准输入
p.StartInfo.RedirectStandardOutput = True '重定向标准输出
p.StartInfo.RedirectStandardError = True '重定向错误输出
p.StartInfo.CreateNoWindow = True '设置不显示窗口
p.Start()
p.StandardInput.WriteLine( "net use \\fwq\abc qwe /user:asd")
p.StandardInput.WriteLine("exit")
If FileSys.DirectoryExists("\\fwq\abc\") Then
Else
e.Cancel=True
msgbox("主机休眠中,无法连接数据库" )
End
第一次打开,显示 主机休眠中,无法连接数据库
再打开,就能进去了!
是不是,代码位置放的不对!
[此贴子已经被作者于2018/3/29 18:17:04编辑过]