将用户配置文件应用到路径中

Apply userprofile into a path

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

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 行指出 "Object Required: Dolpis"

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

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

  1. 所有用户桌面
  2. 所有用户开始菜单
  3. 所有用户程序
  4. 所有用户启动
  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