# Solved: Please explain this .vbs file?



## musiq (Aug 10, 2010)

I was wondering how to run a batch file, with the command prompt(CMD) running invisibly.
I found this code, in .vbs, from winhelponline



> Set WshShell = CreateObject("WScript.Shell")
> WshShell.Run chr(34) & "C:\Batch Files\syncfiles.bat" & Chr(34), 0
> Set WshShell = Nothing


I need some detailed help here in explaining these lines of commands, so I can understand how to use them better.
Thanks in advanced


----------



## leroys1000 (Aug 16, 2007)

Set WshShell = CreateObject("WScript.Shell") 
Basically starts a new windows shell process (command line).

WshShell.Run chr(34) & "C:\Batch Files\syncfiles.bat" & Chr(34), 0
Runs a command and sets the character set for the text string,"C:\Batch Files\syncfiles.bat"

Set WshShell = Nothing
Tells the shell not to display the window.

"C:\Batch Files\syncfiles.bat"
Change this to the file, program or batch file that you want the .vbs file to run
in a hidden window.


----------



## musiq (Aug 10, 2010)

> sets the character set for the text string,"C:\Batch Files\syncfiles.bat"


Sorry, I don't understand what this means. What does it mean by character set for the text string?
I'm sorry for asking such a stupid question. x_x


----------



## leroys1000 (Aug 16, 2007)

"C:\Batch Files\syncfiles.bat" is entered as text and the
Chr(34) is telling the command there is a text string command in quotes.
chr(34) actually = " in ascii text code.
So in ascii the command is actually quoting the quoted text for the command
so the command understands it.
Trying to keep this as simple as possible.

First line runs the command promt.
Second line runs the program or file.
Third line makes it run without showng the window.

The only stupid question is the one that's not asked.


----------



## musiq (Aug 10, 2010)

Now I 100% understand this le!
Thanks for your kindest help and time, leroys1000


----------

