China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-02 08:00
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » VBS cannot copy folders with spaces to system variables View 1,494 Replies 7
Original Poster Posted 2006-10-20 03:57 ·  中国 云南 昆明 电信
初级用户
★★
Credits 134
Posts 50
Joined 2006-03-28 13:50
20-year member
UID 52939
Status Offline
On Error Resume Next
Dim objFSO,oShell
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = WScript.CreateObject("WScript.Shell")
objFSO.Copyfolder "aa 12" , “%USERPROFILE%\My Documents" , OverwriteExisting
oShell.Run "1.exe"

[ Last edited by xg911335 on 2006-10-20 at 03:59 ]
Floor 2 Posted 2006-10-20 04:07 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Remember that %USERPROFILE% seems to be under DOS, and in VBS, you need to use Environment to get the environment variable

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 3 Posted 2006-10-20 05:06 ·  中国 云南 昆明 电信
初级用户
★★
Credits 134
Posts 50
Joined 2006-03-28 13:50
20-year member
UID 52939
Status Offline
Give an example to have a look. Thanks to the solution from the upstairs.
Floor 4 Posted 2006-10-20 07:01 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Just go to script56.chm to see

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 5 Posted 2006-10-20 07:28 ·  中国 湖北 荆门 电信
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline
There are not many VBS scripts in the forum. But if you go through them all, the owner's problem will no longer be a problem.

arrArgs = Array("None", "IE", "All Programs", "Control Panel", "Printers and Faxes", _
"My Documents", "Favorites", "Startup", "Recent Documents", "Send To", _
"Recycle Bin", "Start Menu", "Pending", "My Music", "My Videos", _
"Pending", "Desktop", "My Computer", "Network Neighborhood", "NetHood", _
"Fonts", "Templates", "All User Start Menu", "All User All Programs", _
"All User Startup", "All User Desktop", "MY_AppData", "PrintHood", _
"MY_AppData2", "Pending", "Pending", "All User Favorites", "IE Cache", _
"Cookies", "History", "All User AppData", "Windows", "System32", _
"Programs", "My Pictures", "Current User Root Directory", "Public Components", "Pending", _
"Pending", "Pending", "All User Templates", "Shared Documents", _
"All User Management", "Administrative Tools", "Network Connections", "Pending", "Pending", _
"Pending", "All User Music", "All User Pictures", "All User Videos", _
"Desktop Themes", "Resources2", "none", "CD_Burning")
For i = 1 To UBound(arrArgs)
If arrArgs(i) = "Current User Root Directory" Then intNumber = i
Next

str = "Set objShell = CreateObject(" & Chr(34) & _
"Shell.Application" & Chr(34) & ")" & vbLf & _
"Set objFolder = objShell.Namespace(" & intNumber & ")" & vbLf &_
"Set objFolderItem = objFolder.Self" & vbLf & _
"strDir = objFolderItem.Path"
Execute str
Wscript.Echo "The code to get ★" & strDir & "★:" & vblf & vblf & str
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate "about:blank"
objIE.document.parentwindow.clipboardData.SetData "text", str
objIE.Quit
WScript.Echo "The code has been copied to the clipboard!"

Set objIE = Nothing


Reference link: SendTo + Batch Processing Practical Small Tool - Enhanced Send To
In VBS, you can also get some system directories using Wscript.Shell, but since its content is too little, I rarely use it:

WScript.Echo CreateObject("Wscript.Shell").SpecialFolders("Desktop")

The directories it can get are:

AllUsersDesktop
AllUsersStartMenu
AllUsersPrograms
AllUsersStartup
Desktop
Favorites
Fonts
MyDocuments
NetHood
PrintHood
Programs
Recent
SendTo
StartMenu
Startup

In addition, regarding obtaining environment variables, you can try to implement it using WMI:

For Each x In GetObject("winmgmts:\\.\root\cimv2:Win32_Environment").Instances_
WScript.Echo x.Name & ":" & vbTab & x.VariableValue
Next

Templates
Floor 6 Posted 2006-10-20 07:38 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline

  The version master is really powerful.

  Learned.
Floor 7 Posted 2006-10-20 09:05 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Shell.Application……Using this is enough to handle all paths.

[ Last edited by electronixtar on 2006-10-21 at 04:31 ]

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 8 Posted 2006-10-21 03:15 ·  中国 云南 昆明 电信
初级用户
★★
Credits 134
Posts 50
Joined 2006-03-28 13:50
20-year member
UID 52939
Status Offline
Thanks to all for your guidance.
Forum Jump: