Trying to press keys and shortcuts in a hidden CMD

2019-03-06 12:27发布

I am trying to create a script that will use the copy con to write a file

Set objNetwork = CreateObject("Wscript.Network")
CurrentUser = objNetwork.UserName

Set Wshell = CreateObject("WScript.Shell")

Wshell.Run "%COMSPEC% cd C:\Users\" & CurrentUser & _
  "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup & copy con master.vbs & x = 1 & x=2^Z", 0, True

The problem here is that while using ^Z does simulate the output of Crtl+Z, CMD doesn't treat them the same.

As you can see, I wanted the console window to be hidden, so using something like SendKeys won't work here.

Any suggestions?

标签: cmd vbscript
0条回答
登录 后发表回答