0

我需要获取计算机的用户文件夹名称并将其放入路径中,在本例中为启动和桌面路径。我想出了如何找到用户文件夹名称,但我一直在弄清楚如何将其放入路径中。有谁知道怎么做?

Set WshShell = CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("PROCESS")

这将是一个很大的帮助。

编辑

Set objShell = Wscript.CreateObject("Wscript.Shell")
strPath = objShell.SpecialFolders("Startup")
wscript.echo strPath
dim WSHShell, desktop, pathstring, startup, objFSO
set objFSO=CreateObject("Scripting.FileSystemObject")
Set WSHshell = CreateObject("WScript.Shell")
desktop = WSHShell.SpecialFolders("Desktop")
pathstring = objFSO.GetAbsolutePathName(desktop)
WScript.Echo desktop
set filesys=CreateObject("Scripting.FileSystemObject") 
filesys.CopyFile "desktop", dolpis.vbs,"startup", dolpis.vbs
set objFso=createObject("scripting.fileSystemObject")
set objWShell=wScript.createObject("WScript.Shell")
usrName=objWShell.expandEnvironmentStrings("%USERNAME%")
if objFso.folderExists(strFolder) then
   objFso.copyFile strFileToCopy,strFolder&"\",True
else
   msgbox "The folder " & strFolder & " does not exist"
end if
CreateObject("WScript.Shell").Run("C:\WINNT\system32\notepad.exe")
Set wshshell = wscript.CreateObject("WScript.Shell") 

第 11 行声明“需要对象:Dolpis”

4

1 回答 1

4

WshShell 对象的 SpecialFolders 属性提供对 Windows 特殊文件夹(桌面、收藏夹等)的引用

可用的 Windows 特殊文件夹列表:

  1. 所有用户桌面
  2. 所有用户开始菜单
  3. 所有用户程序
  4. AllUsersStartup
  5. 桌面
  6. 收藏夹
  7. 字体
  8. 我的文件
  9. 网罩
  10. 打印罩
  11. 程式
  12. 最近的
  13. 发送至
  14. 开始菜单
  15. 启动
  16. 模板

Set WshShell = CreateObject("WScript.Shell")
wscript.echo "Desktop Folder = " & WshShell.SpecialFolders("Desktop")
wscript.echo "Startup Folder = " & WshShell.SpecialFolders("Startup")

For i = 0 to WshShell.SpecialFolders.Count -1 
     sf = sf & WshShell.SpecialFolders(i) & vbCr 
Next 
wscript.echo "Special folders of Windows : " & vbCrlf & vbCrlf & sf 

编辑

Option Explicit
Dim WshShell,Desktop,Startup
Set WshShell = CreateObject("WScript.Shell")
Desktop = WshShell.SpecialFolders("Desktop")
Startup = WshShell.SpecialFolders("Startup")
wscript.echo Desktop
wscript.echo Startup
于 2016-05-16T12:29:04.160 回答