Skip to content

Instantly share code, notes, and snippets.

@jbratu
Created March 29, 2021 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbratu/45675d3af94a29c2d9d5a4258c126355 to your computer and use it in GitHub Desktop.
Save jbratu/45675d3af94a29c2d9d5a4258c126355 to your computer and use it in GitHub Desktop.
Function CS_DETACH_VOLUMES_STARTING_WITH(void)
StartingPrefix = '\\server\share\'
StartingPrefixLen = Len(StartingPrefix)
declare function Set_FSError
$Insert Logical
*Readnext through the systables which contains a list of currently attached tables.
TABLE_NAME = "SYSTABLES"
open TABLE_NAME To TABLE else
status = Set_FSError()
return
End
select TABLE
Done = False$
Loop
ReadNext @ID else Done = True$
Until Done Do
read @RECORD From TABLE, @ID Then
Gosub processRecord
End
Repeat
return
*
* End Main
*
processRecord:
//Don't bother processing Index or Dictionary tables
If @ID[1,1] EQ "!" Then Return
If @ID[1,5] EQ "DICT." Then Return
//Check the volume against certain system volumes and exclude them
Vol = Field(@RECORD<1>, "*", 2)
*Exclude tables with no volume
If Vol = '' Then Return
If Vol[1,StartingPrefixLen] _EQC StartingPrefix then
Call Detach_Volume(VOL)
Call Set_Status(0)
end
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment