Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %---------------------------- GET_UNC_DRIVE --------------------------
- % resolve windows drive letter to unc path
- %
- % usage: unc_drive = get_unc_drive(win_drive);
- % input: win_drive -- drive name in windows style A:...Z:
- %
- % output: unc_drive
- % example:
- % UNC = get_unc_drive('N:')
- %
- %-------------------------------------------------------------------------------
- function unc_drive = get_unc_drive(win_drive)
- unc_drive = '';
- [dummy, drivelist] = system('wmic logicaldisk get caption, drivetype, providername');
- drivelist = textscan(drivelist ,...
- '%s %d %s' ,...
- 'MultipleDelimsAsOne', true ,...
- 'HeaderLines' , 1 ,...
- 'Whitespace' , ' \t\b\n' );
- win_drivelist = drivelist{1};
- drivetype = drivelist{2};
- unc_drivelist = drivelist{3};
- posdrive = strncmpi(win_drivelist, win_drive, length(win_drive));
- if any(posdrive)
- if drivetype(posdrive)== 4
- unc_drive = unc_drivelist{posdrive};
- else
- fprintf('%s is not network-drive\n', win_drive)
- end
- else
- fprintf('%s drive does not exist\n', win_drive );
- end
Advertisement
Add Comment
Please, Sign In to add comment