• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 665
  • Last Modified:

Running a command using vbscript with muliple quotes

Hello,

I'm trying to run this simple command using vbscript.

psshutdown.exe -r -m "System is shutting down"

I'm having trouble in Vbscript using the WshShell.Run method because of the additonal quotation marks needed.

I've played around with Chr(34) but still can't get it to work at all.

Any ideas on how I can take the following code and make it work. The -m switch is for the shutdown message. The shutdown message has to be in quotes too.

Set wshShell = CreateObject("WScript.Shell")
wshShell.Run "PsShutdown.exe -r -m "System is shutting down now""

Thanks
0
hpops
Asked:
hpops
2 Solutions
 
hongjunCommented:
Try this

Dim myCommand

myCommand = "PsShutdown.exe -r -m ""System is shutting down now"""
wshShell.Run myCommand
0
 
hongjunCommented:
Use 2 quotes to represent 1 quote
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
So this doesnt' work?

    wshShell.Run "PsShutdown.exe -r -m " & Chr(34) & "System is shutting down now" & Chr(34)
0
 
Leo EikelmanDirector, IT and Business DevelopmentCommented:
Try

Dim sysShutdown as String

sysShutdown = "System is shutting down now"

wshShell.Run "PsShutdown.exe -r -m " & sysShutdown

0
 
hpopsAuthor Commented:
Thanks to both of you. Both methods work and give me a choice on which direction to take. I like both solutions but for my needs this time around Idle Mind's solution fits me a bit better. I like hongjun's method too because it will come in handy for another project I'm working on.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now