windows build script, get the temp variable from environment, avoiding potential permission problems
authorkoda
Tue, 28 May 2013 16:07:22 +0200
changeset 9069 24a2da6e5a22
parent 9068 3401390f03cf
child 9070 604273fb8a58
windows build script, get the temp variable from environment, avoiding potential permission problems
tools/w32DownloadUnzip.vbs
--- a/tools/w32DownloadUnzip.vbs	Tue May 28 15:38:28 2013 +0200
+++ b/tools/w32DownloadUnzip.vbs	Tue May 28 16:07:22 2013 +0200
@@ -7,6 +7,7 @@
 ' References
 '   http://superuser.com/questions/59465/is-it-possible-to-download-using-the-windows-command-line
 '   http://stackoverflow.com/questions/1021557/how-to-unzip-a-file-using-the-command-line
+'   http://stackoverflow.com/questions/424331/get-the-current-temporary-directory-path-in-vbscript
 
 Set ArgObj = WScript.Arguments
 
@@ -23,7 +24,8 @@
     End if
 End if
 
-strHDLocation = "C:\Windows\Temp\temp.zip"
+' Temporary directory
+strHDLocation = WScript.CreateObject("Scripting.FileSystemObject").GetSpecialFolder(2) + "\hwlibtemp.zip"
 
 ' Fetch the file
 WScript.Echo ( "Trying to download from " & strFileURL)
@@ -37,7 +39,7 @@
     objADOStream.Type = 1 'adTypeBinary
 
     objADOStream.Write objXMLHTTP.ResponseBody
-    objADOStream.Position = 0    'Set the stream position to the start
+    objADOStream.Position = 0 'Set the stream position to the start
 
     Set objFSO = Createobject("Scripting.FileSystemObject")
     If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
@@ -46,12 +48,12 @@
     objADOStream.SaveToFile strHDLocation
     objADOStream.Close
     Set objADOStream = Nothing
+    Set objXMLHTTP = Nothing
 Else
     WScript.Echo ("Error downloading file (error code: " & objXMLHTTP.Status & ")")
     Set objXMLHTTP = Nothing
     WScript.Quit
 End if
-Set objXMLHTTP = Nothing
 
 WScript.Echo ( "Extracting file to " & strOutputPath)
 Set objShell = CreateObject( "Shell.Application" )