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-04 11:49
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Question about runas that's really confusing me, please help take a look View 758 Replies 2
Original Poster Posted 2007-04-29 12:46 ·  中国 重庆 长寿区 电信
初级用户
Credits 101
Posts 47
Joined 2007-04-18 16:05
19-year member
UID 85634
Gender Male
Status Offline
I mapped a shared folder from the network to local, with drive letter Z:, and under it there is a folder named 123.
If I directly execute the batch file 1.bat on drive E and enter the administrator password, it can copy normally. The contents are as follows:
runas /noprofile /savecred /user:administrator\administrator e:\1.bat
xcopy /e /z /d /y /i /k /h /r /v /c z:\123 e:\123
exit

But if I use the following VBS script to call 1.bat, 1.bat does run, yet it says it can't find the drive letter.
Dim oShell
Set oShell = WScript.CreateObject("WScript.Shell")
oshell.Run "runas /noprofile /savecred /user:administrator\administrator e:\1.bat"
wscript.sleep 100
oshell.SendKeys "123"
wscript.sleep 10
oshell.SendKeys "{ENTER}"

Question for all you experts, where exactly is the problem here? I really can't figure out what exactly went wrong.
Floor 2 Posted 2007-04-30 01:27 ·  中国 重庆 长寿区 电信
初级用户
Credits 101
Posts 47
Joined 2007-04-18 16:05
19-year member
UID 85634
Gender Male
Status Offline
Does nobody know this?
Floor 3 Posted 2007-04-30 02:31 ·  中国 重庆 长寿区 电信
初级用户
Credits 101
Posts 47
Joined 2007-04-18 16:05
19-year member
UID 85634
Gender Male
Status Offline
Could it be that calling it with VBS and running it directly are different in terms of environment?
Forum Jump: