开发者

Defining a save path in VB

The script creates a txt file of info from the users PC then saves it to a shared directory folder F:\InstalledSoftware\

If WriteFile(s, sFileName) Then
  'optional prompt for display
  If MsgBox("Finished processing.  Results saved to " & sFileName & _
            vbcrlf & vbcrlf & "Do you want to view the results now?", _
            4 + 32, sTitle) = 6 T开发者_开发知识库hen
    WScript.CreateObject("WScript.Shell").Run """" & sFileName & """", 9
  End If
End If

A) sFileName = "F:\InstalledSoftware\" & sCompName & "_" & GetDTFileName() & "_Software.txt"

B) sFileName = sCompName & "_" & GetDTFileName() & "_Software.txt"

both result in a file being created e.g “ JOHNPC_05112011_093842_Software.txt”

but B correctly creates it in the current active directory.

Two problems, As I have as shared drive, if I email the link to the VB script, I have to use exhibit A as exhibit B uses the current active directory. The second problem is the F: drive is mapped on some machines as a different drive letter J or K or in virtual environments a different drive. But exhibit B will always work as long as I am in the correct folder.

Is there a different way of designating the path. i.e

IP Address or DNS name that does not use a Drive letter?

sFileName = "????????????????\InstalledSoftware\" & sCompName & "…………..


Simply use the UNC path of the location the drive is mapped to;

sFileName = "\\server_name_or_ip\optional_path\InstalledSoftware\" & sCompName & ..."

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜