When I use a batch file to create the file invisible.vbs, then delete, it stops with an error. Basically, what I want to do is to have the batch file make this file.
This is the error that I get when I run the batch file:
C:\Users\HP\Desktop>"New Text Document.bat"
CreateObject("Wscript.Shell").Run """"
'WScript.Arguments' is not recognized as an internal or external command, operable program or batch file.
'""""' is not recognized as an internal or external command, operable program or batch file.
This is what’s in the batch file:
@ECHO OFF
CD /D %~dp0
ECHO\ CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0,False>>Invisible.vbs
::What I want to do with the file is here
DEL %CD%\invisible.vbs /Q /S
I notice that the file is generated, but it is empty, and therefore does nothing when I try to use it to make another batch file invisible.
This is caused by the
&symbol in your echo statement. It needs to be escaped by the batch escape character^when using it literally^&. You may also want to use the single output redirection operator>(overwrite existing) instead of the double>>(append to existing).Another tip would be to use the
%TEMP%directory variable when creating throw away files.