Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   Программирование и базы данных (http://forum.oszone.net/forumdisplay.php?f=21)
-   -   [решено] Переменные в fso.GetSpecialFolder (http://forum.oszone.net/showthread.php?t=261539)

includer-test 30-05-2013 14:14 2159282

Переменные в fso.GetSpecialFolder
 
Всем доброго врмени суток. Небольшой вопрос по VBS.

Есть у меня функция, которая сохраняет файл в папке temp:

Код:

Function SaveFile(what)
  Set fso = CreateObject("Scripting.FileSystemObject")
  tempFolder = fso.GetSpecialFolder(2)
  'tempFolder = "C:\users\%userprofile%\" не работает
  filepath = tempFolder+"\weather.xml"
  Dim fso1, tf
  Set fso1 = CreateObject("Scripting.FileSystemObject")
  Set tf = fso1.CreateTextFile(filepath, True, True)  'rewrite, unicode
  tf.Write(what)
  tf.Close
 End Function

Насколько я понимаю у fso.GetSpecialFolder есть следующие параметры:

WindowsFolder - 0 -The Windows folder contains files installed by the Windows operating system.
SystemFolder - 1 - The System folder contains libraries, fonts, and device drivers.
TemporaryFolder - 2 - The Temp folder is used to store temporary files. Its path is found in the TMP environment variable.

Думаю понятно какие папки.

Дико извиняюсь за вопрос, но с VBS я слабо знаком.
Каким образом можно сохранить файл в папку %userprofile% ?

Iska 30-05-2013 15:10 2159329

Код:

Option Explicit

' 1.
Dim objWshShell

Set objWshShell = WScript.CreateObject("WScript.Shell")
WScript.Echo objWshShell.ExpandEnvironmentStrings("%UserProfile%")

' 2.
Dim objShell

Set objShell = WScript.CreateObject("Shell.Application")
WScript.Echo objShell.NameSpace("shell:Profile").self.Path

WScript.Quit 0


includer-test 30-05-2013 16:36 2159399

Спасибо, помогло.


Время: 05:53.

Время: 05:53.
© OSzone.net 2001-