Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to execute batch file (or unzip) on UNC drive?
Message
 
 
To
18/10/2005 15:02:25
General information
Forum:
Windows
Category:
Computing in general
Miscellaneous
Thread ID:
01059974
Message ID:
01060017
Views:
15
Thank you, Tracy. I will try the code.

>You might want to check for all mapped drives first. If a drive letter is already mapped, it will fail. I got the below code from the UT along time ago:
>
>* Constants for drive types.
>#DEFINE DRIVE_UNKNOWN 0
>#DEFINE DRIVE_NO_ROOT_DIR 1
>#DEFINE DRIVE_REMOVABLE 2
>#DEFINE DRIVE_FIXED 3
>#DEFINE DRIVE_REMOTE 4
>#DEFINE DRIVE_CDROM 5
>#DEFINE DRIVE_RAMDISK 6
>#DEFINE CR CHR(13)
>
>DECLARE INTEGER GetLogicalDrives IN Win32API
>DECLARE INTEGER GetDriveType IN Win32API STRING RootPath
>
>PRIVATE lcDrivestring, lcDriveRoot, liDrivelist, lcDrives, i
>lcDrives = ""
>
>* GetLogicalDrives returns a 32-bit value containing a list of
>* available drives. If the specific bit is ON, the drive letter
>* corresponding to that position exists.
>liDrivelist = GetLogicalDrives()
>
>* Check each of the bits
>FOR i = 0 TO 31
>	IF BITTEST(liDrivelist, i)
>* If the 0th bit is ON, that means drive 'A:',
>* the 2nd bit is 'C:", etc.
>		lcDriveRoot = CHR(65 + i) + ":\"
>* Perform a GetDriveType to determine if it is a floppy, CD, etc.
>		lcDrivetype = GetDriveType(lcDriveRoot)
>		DO CASE
>			CASE lcDrivetype = DRIVE_UNKNOWN
>				lcDrivestring = "Cannot be determined"
>			CASE lcDrivetype = DRIVE_NO_ROOT_DIR
>				lcDrivestring = "Root directory does not exist"
>			CASE lcDrivetype = DRIVE_REMOVABLE
>				lcDrivestring = "Floppy/removable drive"
>			CASE lcDrivetype = DRIVE_FIXED
>				lcDrivestring = "Hard drive/nonremovable drive"
>			CASE lcDrivetype = DRIVE_REMOTE
>				lcDrivestring = "Remote/Network drive"
>				lcunc=GetUNCForDriveLetter(LEFT(lcDriveRoot,2))
>				IF TYPE('lcunc')="C" .AND. !EMPTY(lcunc)
>					lcDrivestring = lcunc
>				ENDIF
>			CASE lcDrivetype = DRIVE_CDROM
>				lcDrivestring = "CD-ROM drive"
>			CASE lcDrivetype = DRIVE_RAMDISK
>				lcDrivestring = "RAM disk"
>		ENDCASE
>		lcDrives = lcDrives + lcDriveRoot + " " + lcDrivestring + CR
>	ENDIF
>NEXT
>
>=MESSAGEBOX(lcDrives, ;
>	0 + 64 + 0,'All Drives Listing')
>RETURN
>
>
>FUNCTION GetUNCForDriveLetter
>LPARAMETER cDriveLetterToCheck
>LOCAL cBuffer, nResult, lcunc
>IF TYPE('cDriveLetterToCheck') # 'C' OR ;
>		LEN(cDriveLetterToCheck) < 2 OR ;
>		SUBSTR(cDriveLetterToCheck,2,1) # ':' OR ;
>		! BETWEEN(UPPER(LEFT(cDriveLetterToCheck,1)),'A','Z')
>	RETURN ''
>ENDIF
>DECLARE INTEGER WNetGetConnection IN Win32API ;
>	STRING   @cLocalDrive, ;
>	STRING   @cRemoteUNCBuffer, ;
>	INTEGER  @nSizeOfBuffer
>cBuffer = SPACE(511)
>nResult = WNetGetConnection(LEFT(cDriveLetterToCheck,2), ;
>	@cBuffer, ;
>	511)
>IF nResult # 0
>	RETURN ''
>ELSE
>	lcunc=LEFT(cBuffer,AT(CHR(0),cBuffer)-1)
>	RETURN lcunc
>*RETURN LEFT(cBuffer,AT(CHR(0),cBuffer)-1)
>ENDIF
>
>
>
>>>>>I think WinXP can open ZIP-ed files. Also why you dind't make backup as a Selfextract file? The you didn't need bat, PKUNZIP etc. files.
>>>>
>>>>Yes, you are right, WinXP will open my ZIP files. But often times the computer is Win2K where this feature is not available. I could do the Selfextracting file, I have not thought about it. Thank you very much.
>>>>
>>>>But I am still wondering if there are other ways to open my .ZIP file, besides the Selfextracting approach.
>>>
>>>Don't know, maybe something like temporary maping the drive and then release it in BAT file:
>>>NET USE Z: \\UNCpathHere
>>>pkunzip z:\zip file
>>>NET USE Z: /DELETE
>>
>>I will try this approach. I know I tried to map the drive from the Windows Explorer and had a problem (maybe it was looking for a password). But maybe from another letter-mapped drive it will work.
>>
>>Thank you very much for your suggestion.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform