将userprofile应用于路径

时间:2016-05-16 00:21:29

标签: windows vbscript windows-2000

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

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”

1 个答案:

答案 0 :(得分:4)

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

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

  1. AllUsersDesktop
  2. AllUsersStartMenu
  3. AllUsersPrograms
  4. AllUsersStartup
  5. 桌面
  6. 收藏夹
  7. 字体
  8. 我的文档
  9. NETHOOD
  10. PRINTHOOD
  11. 程序
  12. 最近
  13. 的SendTo
  14. 的StartMenu
  15. 启动
  16. 模板
  17. 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