我有一个vbscript如下:set nice = wscript.createobject(" wscript.shell")。现在我希望为登录系统的任何人动态选择用户名。 [英] I have a vbscript as follows: set nice = wscript.createobject ("wscript.shell"). Now I want the username to be picked dynamically for whoever is logged in the system.
问题描述
我有一个vbscript如下:
set nice = wscript.createobject(wscript.shell)
如有错误,请继续下载
nice.runcmd.exe
wscript .sleep 400
nice.sendkeyscd C:\ Users \ Annamaria.Mikecz01 \Desktop\CENT-ERIKA-GUI
nice.sendkeys{enter}
nice.sendkeyscapture.jpg
nice.sendkeys{enter}
wscript.sleep 300
nice.sendkeys%{f4}
现在我想要为登录系统的任何人动态选择用户名。所以我应该用什么代码替换这个代码:C:\ Users \ Annamaria.Mikecz01 \Desktop。
请帮助
我尝试过:
set nice = wscript.createobject(wscript.shell)
on错误恢复下一个
nice.runcmd.exe
wscript.sleep 400 >
nice.sendkeyscd C:\ Users\Annamaria.Mikecz01\Desktop\CENT-ERIKA-GUI
nice.sendkeys {enter}
nice.sendkeyscapture.jpg
nice.sendkeys{enter}
wscript.sleep 300
nice.sendkeys%{f4}
i have a vbscript as follows :
set nice = wscript.createobject ("wscript.shell")
on error resume next
nice.run "cmd.exe"
wscript.sleep 400
nice.sendkeys "cd C:\Users\Annamaria.Mikecz01\Desktop\CENT-ERIKA-GUI"
nice.sendkeys "{enter}"
nice.sendkeys "capture.jpg"
nice.sendkeys "{enter}"
wscript.sleep 300
nice.sendkeys "%{f4}"
Now I want the username to be picked dynamically for whoever is logged in the system. So with what code should i replace this one : "C:\Users\Annamaria.Mikecz01\Desktop".
Please help
What I have tried:
set nice = wscript.createobject ("wscript.shell")
on error resume next
nice.run "cmd.exe"
wscript.sleep 400
nice.sendkeys "cd C:\Users\Annamaria.Mikecz01\Desktop\CENT-ERIKA-GUI"
nice.sendkeys "{enter}"
nice.sendkeys "capture.jpg"
nice.sendkeys "{enter}"
wscript.sleep 300
nice.sendkeys "%{f4}"
推荐答案
特殊文件夹 - VBScript - SS64.com [ ^ ]
所以:
Special folders - VBScript - SS64.com[^]
So:
Dim folderPath
folderPath = nice.SpecialFolders("Desktop")
folderPath = folderPath & "\CENT-ERIKA-GUI"
nice.SendKeys "cd "
nice.SendKeys folderPath
nice.SendKeys "{enter}"
然而,依靠 SendKeys
并不是一个好主意。如果您只是想在其关联的应用程序中打开文件,请使用运行
方法。
However, it's not a good idea to rely on SendKeys
. If you're just trying to open a file in its associated application, use the Run
method instead.
Dim nice
Dim filePath
Set nice = Wscript.CreateObject("wscript.shell")
filePath = nice.SpecialFolders("Desktop")
filePath = filePath & "\CENT-ERIKA-GUI\capture.jpg"
nice.Run filePath
这篇关于我有一个vbscript如下:set nice = wscript.createobject(" wscript.shell")。现在我希望为登录系统的任何人动态选择用户名。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!