vbs Script Whats wrong

Associate
Joined
24 Oct 2006
Posts
1,752
Location
Sheffield
this is my script why wont it wrok eventualy it will delete autoexec.cfg and put my fps configh there form the script but why wont it work now

Code:
Set objShell = CreateObject("Wscript.Shell")
Set WshShell = WScript.CreateObject("WScript.Shell")

ts = InputBox("Please enter your steam username")

WshShell.Run ("C:\Program Files\Steam\SteamApps\" & ts & "\""counter-strike source\cstrike\cfg\autoexec.cfg")

'End
 
Last edited:
still dosent work

this is the current script

Code:
Set objShell = CreateObject("Wscript.Shell")
Set WshShell = WScript.CreateObject("WScript.Shell")

ts = InputBox("Please enter your steam username")


	

WshShell.Run "C:\Program Files\Steam\SteamApps\ & ts & \counter-strike source\cstrike\cfg\autoexec.cfg"


'End


i think its got something to do with the space between program files and strike source
 
Last edited:
WshShell.Run "C:\Program Files\Steam\SteamApps\" & ts & "\counter-strike source\cstrike\cfg\autoexec.cfg"
 
Well looking at it you cant "execute" a CFG file can you, as in you cant double click that file and expect it to run, am i right?

Does it not have to be executed within Counterstrike?
 
You can't just shell out to a .cfg file - it should be an executable file.

The .cfg file isn't executable, it's executed BY something else (notepad/whatever) - to open a .txt file, for example, you'd have to shell out to notepad.exe passing the .cfg file as a parameter "notepad.exe c:\boot.ini" or something of that ilk.
 
right ui cant open the folder nevermind the cfg so instead of \autoexec.cfg just \ till dosent work
 
If there is spaces in the path you have to surround it in quotes so:

WshShell.Run """" & "C:\Program Files\Steam\SteamApps\" & cStr(ts) & "\counter-strike source\cstrike\cfg\autoexec.cfg" & """"

Can you ShellExec in vbscript? That will execute the file with the registered program. Like .txt with notepad.
 
ta theat worked

can you explain this
Code:
" & cStr(ts) & "
and this
Code:
& """"
the & sign
 
cStr 'converts' a variable of one type into a string. Technically it isn't needed as it will be implicitly converted but i prefer to keep it in.

The ampersands (&) concatenate strings together.

"""" is a string that contains a single quote (")
 
Back
Top Bottom