Click here to Skip to main content
15,907,395 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I'm having a problem making a vbs script I tried using other articles code failed.so pls help me

What I have tried:

I tried using other articles code
Posted
Updated 20-Aug-22 6:27am

Maybe you show what you have tried?

Not familar with vbs but after a short google I tried ...
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""C:\Windows\System32\notepad.exe""")
Set objShell = Nothing


... and works fine for me ;)
 
Share this answer
 
Comments
lurew levf 11-Nov-21 15:17pm    
the script gave me an error
0x01AA 11-Nov-21 15:29pm    
And maybe you are willing to tell us what the error message is?
lurew levf 11-Nov-21 16:12pm    
yes
0x01AA 11-Nov-21 16:13pm    
and the error message is?
lurew levf 11-Nov-21 16:15pm    
it was Failed to execute script crazyrockerror
You can do in one line without using/set variables:

CreateObject("Wscript.Shell").Run """C:\Windows\System32\notepad.exe""", 1, True

object.Run(strCommand, [intWindowStyle], [bWaitOnReturn]:)
 
Share this answer
 
Maybe you show what you tried...

No idea about vbs, but after google and tried this ....

Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""C:\Windows\System32\notepad.exe""")
Set objShell = Nothing


... and it works fine for me ;)
 
Share this answer
 
Comments
0x01AA 11-Nov-21 15:22pm    
Before somebody other thinks down vote is needed have a look here Bugs and Suggestions[^]
Try with
VBScript
Option Explicit
Dim wShell : Set wShell = CreateObject("wScript.Shell")
wShell.run Chr(34) & "C:\Windows\System32\notepad.exe" & Chr(34)

REM Optional - Set wShell = (Nothing)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900