Jump to content

Embedding the " in a string


Recommended Posts

I am creating a shortcut to cmd.exe as follows:

FileCreateShortcut(@SystemDir&"\cmd.exe", "My Link.lnk", $installDir, "/e:on /f:on /K "&$installDir&"\envVars.bat && cls", "Command Shell", $installDir&"\bin\myExe.exe")

The problem is that the link is invalid, because in order to concatenate two commands when using the option /K in cmd .exe the string requires to be within " characters. How can I embed the " character within the string?

Link to post
Share on other sites

Create a new variable:

$cmdString = "/e:on /f:on /K "&Chr(34)&$installDir&"\envVars.bat && cls"&Chr(34)

Then

FileCreateShortcut(@SystemDir&"\cmd.exe", "My Link.lnk", $installDir, $cmdString, "Command Shell", $installDir&"\bin\myExe.exe")

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...