vbscript - How to make this script actually stop when canceled? -


i've got working script, if user launches , aborts cancel button script generates prescribed folders in whatever directory file explorer opens to. that's not good. need script stop if user cancels, have no idea how that?

here's code:

' 26apr2015 jkw -- q&d  option explicit  dim g_fso:  set g_fso = createobject("scripting.filesystemobject")  dim tgt: tgt = browsefolder("m:\marcstone bids", false)   dim subdirs:  subdirs = array(_ "anchors",_ "color",_ "engineering",_ "mold drawings",_ "plans , specs",_ "plans , specs\plans",_ "plans , specs\specs",_ "revisions , cost changes",_ "shops",_ "managing documents",_ "managing documents\accounting",_ "managing documents\approvals",_ "managing documents\bid documents",_ "transmittals"_ )  dim subdir each subdir in subdirs     g_fso.createfolder(tgt & "\" & subdir) next  function browsefolder( mystartlocation, blnsimpledialog ) ' function generates browse folder dialog ' , returns selected folder string. ' ' arguments: ' mystartlocation   [string]  start folder dialog, or "my computer", or '                             empty string open in "desktop\my documents" ' blnsimpledialog   [boolean] if false, additional text field '                             displayed folder can selected '                             typing qualified path ' ' returns:          [string]  qualified path selected folder ' ' based on hey scripting guys article ' "how can show users dialog box lets them select folders?" ' http://www.microsoft.com/technet/scriptcenter/resources/qanda/jun05/hey0617.mspx ' ' function written rob van der woude ' http://www.robvanderwoude.com     const my_computer   = &h11&     const window_handle = 0 ' must 0      dim numoptions, objfolder, objfolderitem     dim objpath, objshell, strpath, strprompt      ' set options dialog window     strprompt = "select folder in create subdirectories:"     if blnsimpledialog = true         numoptions = 0      ' simple dialog     else         numoptions = &h10&  ' additional text field type folder path     end if      ' create windows shell object     set objshell = createobject( "shell.application" )      ' if specified, convert "my computer" valid     ' path windows shell's browsefolder method     if ucase( mystartlocation ) = "my computer"         set objfolder = objshell.namespace( my_computer )         set objfolderitem = objfolder.self         strpath = objfolderitem.path     else         strpath = mystartlocation     end if      set objfolder = objshell.browseforfolder( window_handle, strprompt, _                                               numoptions, strpath )      ' quit if no folder selected     if objfolder nothing         browsefolder = ""         exit function     end if      ' retrieve path of selected folder     set objfolderitem = objfolder.self     objpath = objfolderitem.path      ' return path of selected folder     browsefolder = objpath end function 

help has sample code. line need. if (not objfolder nothing) then

function fnshellbrowseforfoldervb()     dim objshell     dim ssfwindows     dim objfolder      ssfwindows = 36     set objshell = createobject("shell.application")         set objfolder = objshell.browseforfolder(0, "example", 0, ssfwindows)             if (not objfolder nothing)                 'add code here.             end if         set objfolder = nothing     set objshell = nothing end function 

then err.raise num or wscript.quit


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -