域登入延遲對映驅動器的指令碼

2021-05-10 22:52:46 字數 2412 閱讀 5746

'on error resume next

'定義shell物件

dim wshshell

set wshshell = createobject("wscript.shell")

'延時3分鐘

wscript.sleep 180000

'定義網路物件

dim ws

set ws = createobject("wscript.network")

'定義檔案物件

dim ofso

set ofso = createobject("scripting.filesystemobject")

'判斷u盤是否存在

uboolfileexists = ofso.fileexists("u:/nodel")

'如果不存在則自動對映

if not uboolfileexists=true then

ws.mapnetworkdrive  "u:","//search/info","true","aa","11"

dim file1

set file1=ofso.createtextfile( "u:/nodel",2,true)

file1.writeline "請不要刪除這個檔案,系統管理員"

file1.close

dim vf1

set vf1 = ofso.getfile("u:/nodel")

vf1.attributes = 6

set vf1 = nothing

set file1 = nothing

end if

'判斷v盤是否存在

vboolfileexists = ofso.fileexists("v:/nodel")

'如果不存在則自動對映

if not vboolfileexists=true then

ws.mapnetworkdrive  "v:","//192.17.122.191/e","true","hhh","123456"

dim file2

set file2=ofso.createtextfile( "v:/nodel",2,true)

file2.writeline "請不要刪除這個檔案,系統管理員"

file2.close

dim vf2

set vf2 = ofso.getfile("v:/nodel")

vf2.attributes = 6

set vf2 = nothing

set file2 = nothing

end if

'判斷x盤是否存在

xboolfileexists = ofso.fileexists("x:/nodel")

'如果不存在則自動對映

if not xboolfileexists=true then

ws.mapnetworkdrive  "x:","//192.17.60.10/公司","true","jj","111"

dim file3

set file3=ofso.createtextfile( "x:/nodel",2,true)

file3.writeline "請不要刪除這個檔案,系統管理員"

file3.close

dim vf3

set vf3 = ofso.getfile("x:/nodel")

vf3.attributes = 6

set vf3 = nothing

set file3 = nothing

end if

'判斷w盤是否存在

wboolfileexists = ofso.fileexists("w:/nodel")

'如果不存在則自動對映

if not wboolfileexists=true then

ws.mapnetworkdrive  "w:","//192.17.60.4/個人資料夾/"&ws.username,"true"

dim file4

set file4=ofso.createtextfile( "w:/nodel",2,true)

file4.writeline "請不要刪除這個檔案,系統管理員"

file4.close

dim vf4

set vf4 = ofso.getfile("w:/nodel")

vf4.attributes = 6

set vf4 = nothing

set file4 = nothing

end if

msgbox "驅動器對映完成!",vbokonly+vbinformation,"指令碼提示"

'清除記憶體占用

set ofso = nothing

set ws = nothing

set wshshell = nothing

C 對映網路驅動器

public enum error id public enum resource scope public enum resource type public enum resource usage public enum resource displaytype structlayout lay...

C 對映網路驅動器

using system.runtime.interopservices using system.io using system.text class drivereflection dllimport mpr.dll charset charset.unicode,setlasterror tr...

C 對映網路驅動器

using system.runtime.interopservices using system.io using system.text class drivereflection dllimport mpr.dll charset charset.unicode,setlasterror tr...