option ExplicitDim Site, SitePath, ComputerName, File, IISOBJ, FSO, TEXTFile, Line, LineNumber Dim bits, DirName, DirPath, objServer, WshNetwork Dim Computer,UserGroup,HomeDir,CreateUser,UserObject,User,Password,Description,Fullname,UserName Site = "MSFTPSVC/1" DirPath="C:\DynaMate\Embedded\Configurations" DirName="DM_CONFIG" Set WshNetwork = WScript.CreateObject("WScript.Network") ComputerName = WshNetwork.ComputerName Set objServer=GetObject("IIS://"&ComputerName&"/MSFTPSVC/1/ROOT") SET Computer=GetObject("WinNT://"&Computername&",computer") SET UserGroup=GetObject("WinNT://"&Computername&"/Users,group")
Computer.Filter = Array("user") HomeDir = DirPath CreateUser=True For Each UserObject In Computer If UCASE(UserObject.name) = UCASE(UserName) Then Wscript.Echo "User "&DirName&" exists." CreateUser = False Wscript.Quit(1) End If Next sub ShowError() WScript.echo "Error = 0x" & hex(err) & " - " & Err.Description end sub
sub CreateVirtualDir(Sitepath, vRoot, DirName, DirPath) dim VDir on error resume next Set vDir = getObject(Sitepath & "/" & DirName) if (err = 0) then WScript.echo "Skipping " & DirName & " already exists!" exit sub end if err.clear set VDir = nothing Set vDir = vRoot.Create("IIsFtpVirtualDir", DirName) If (Err <> 0) Then WScript.echo "Unable to create virutal directory: " & DirName call ShowError() else 'Set the new virtual directory path vDir.AccessRead = true vDir.AccessWrite = true vDir.Path = DirPath If (Err <> 0) Then WScript.echo "Unable to bind the path : " & DirPath call ShowError() else 'Save the changes vDir.SetInfo If (Err <> 0) Then WScript.echo "Unable to save new virtual directory : " & DirName call ShowErro else WScript.Echo "FTP Virtual Dir Creat Correctament : FTPVDir: " & DirName End If End If End If End Sub CreateVirtualDir Site,objserver,DirName,DirPath DirPath="C:\DynaMate\Embedded\sw_ver" DirName="DM_SWLIB" CreateVirtualDir Site,objserver,DirName,DirPath DirPath="C:\DynaMate\DMS" DirName="DM_ROOT" CreateVirtualDir Site,objserver,DirName,DirPath
|