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. AllUsersStartMenu
  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
于 2016-05-16T12:29:04.160 に答える