svn commit: samba r16034 - in branches/SOC/bnh: .
brad at samba.org
brad at samba.org
Sat Jun 3 22:42:26 GMT 2006
Author: brad
Date: 2006-06-03 22:42:25 +0000 (Sat, 03 Jun 2006)
New Revision: 16034
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16034
Log:
Removed smb_delshare.vbs and replaced with smb_delshare.wsf.
smb_delshare.wsf no longer exits if either the share or the directory is not found, as smb_delshare.vbs did.
Added:
branches/SOC/bnh/smb_delshare.wsf
Removed:
branches/SOC/bnh/smb_delshare.vbs
Modified:
branches/SOC/bnh/ads_deluser.wsf
Changeset:
Modified: branches/SOC/bnh/ads_deluser.wsf
===================================================================
--- branches/SOC/bnh/ads_deluser.wsf 2006-06-03 19:30:38 UTC (rev 16033)
+++ branches/SOC/bnh/ads_deluser.wsf 2006-06-03 22:42:25 UTC (rev 16034)
@@ -29,7 +29,7 @@
' Bind to the DC.
set rootDSE = getObject("LDAP://rootDSE")
-Set container = getObject("LDAP://CN=Users," _
+set container = getObject("LDAP://CN=Users," _
& rootDSE.get("defaultNamingContext"))
' Delete the user account.
Deleted: branches/SOC/bnh/smb_delshare.vbs
===================================================================
--- branches/SOC/bnh/smb_delshare.vbs 2006-06-03 19:30:38 UTC (rev 16033)
+++ branches/SOC/bnh/smb_delshare.vbs 2006-06-03 22:42:25 UTC (rev 16034)
@@ -1,51 +0,0 @@
-const READ_ONLY = 1
-const USAGE_STATEMENT = "Usage: cscript smb_delshare.vbs /sharename:<share name> /sharepath:<share path>"
-const NEW_WINDOW_MINIMIZED = 7
-
-' This function returns the contents of a file.
-' When passed the name of a .vbs script and passed to execute, the contents
-' of the script are visible within the relevant scope of this script.
-function include(library_filename)
- dim filesystem_object, file
- set filesystem_object = createobject("scripting.filesystemobject")
- set file = filesystem_object.opentextfile(library_filename, READ_ONLY)
-
- include = file.readall
- set file = Nothing
- set filesystem_object = nothing
-end function
-
-execute include("common.vbs")
-
-' Required command line options
-dim required_options, provided_options
-
-required_options = array("sharename", "sharepath")
-set provided_options = wscript.arguments.named
-
-set setup_options = new setup_object
-setup_options.check_options provided_options, required_options
-
-if setup_options.error_code = RTN_ERR then
- setup_options.list_missing_options
- stdout.writeline USAGE_STATEMENT
- wscript.quit(setup_options.error_code)
-end if
-
-sharename = provided_options.item("sharename")
-pathname = provided_options.item("sharepath")
-
-' Check if the directory exists, and exit if it does not.
-set filesystemobject = createobject("scripting.filesystemobject")
-if not filesystemobject.folderexists(pathname) then
- stdout.write "Error: Directory " & pathname & " does not exist. Exiting."
- wscript.quit
-end if
-
-' Delete the share.
-set shell = wscript.createobject("wscript.shell")
-netsharecmd = "net share " & sharename & " /DELETE"
-shell.run netsharecmd, NEW_WINDOW_MINIMIZED, True
-
-' Delete the directory.
-filesystemobject.deletefolder(pathname)
Added: branches/SOC/bnh/smb_delshare.wsf
===================================================================
--- branches/SOC/bnh/smb_delshare.wsf 2006-06-03 19:30:38 UTC (rev 16033)
+++ branches/SOC/bnh/smb_delshare.wsf 2006-06-03 22:42:25 UTC (rev 16034)
@@ -0,0 +1,56 @@
+<package>
+<job id=smb_delshare>
+<script language="VBScript" src="common.vbs">
+
+' A windows script (.wsf) to remove a shared directory, written in VBScript.
+' Copyright Brad Henry <brad at samba.org> 2006
+' Released under the GNU GPL v2 or later.
+
+const USAGE_STATEMENT = "Usage: cscript smb_delshare.vbs /sharename:<share name> /sharepath:<share path>"
+const NEW_WINDOW_MINIMIZED = 7
+
+on error resume next
+
+' Required command line options
+dim required_options, provided_options
+
+required_options = array("sharename", "sharepath")
+set provided_options = wscript.arguments.named
+
+set setup_options = new setup_object
+setup_options.check_options provided_options, required_options
+
+if setup_options.error_code = RTN_ERR then
+ setup_options.list_missing_options
+ stdout.writeline USAGE_STATEMENT
+ wscript.quit(setup_options.error_code)
+end if
+
+sharename = provided_options.item("sharename")
+pathname = provided_options.item("sharepath")
+
+' Delete the share.
+set shell = wscript.createObject("wscript.shell")
+netsharecmd = "net share " & sharename & " /DELETE"
+error_code = shell.run(netsharecmd, NEW_WINDOW_MINIMIZED, True)
+if error_code = 0 then
+ stdout.writeline "Share " & sharename & " removed."
+else
+ stdout.writeline "Error: " & netsharecmd & " returned " _
+ & error_code & "."
+end if
+
+' Delete the directory.
+set fileSystemObject = createObject("scripting.fileSystemObject")
+fileSystemObject.deleteFolder(pathname)
+if err.number <> 0 then
+ stdout.writeline "An unhandled error occurred while removing " _
+ & "the directory " & pathname & "."
+ report_error
+ wscript.quit(err.number)
+end if
+stdout.writeline "Directory " & pathname & " removed."
+
+</script>
+</job>
+</package>
More information about the samba-cvs
mailing list