Characters in a batch file string variable

Kiran6699

How can I add characters such as ';' ,'+', '=' into a string variable in a batch file?

Basically I am writing a batch file to write the psmodulepath of Powershell.

set "VAR=$env:PSmodulepath=$env:PSmodulepath+;C:\Powershellscripts\modules"

PowerShell.exe %VAR%

pause

I know this above code wont do me any good but I just want to understand how to pass the string correctly. When I run the batch file, I get the error as below :

C:\Users\Kiran_Vasanth\Desktop\Powe>PowerShell.exe $env:PSmodulepath=$env:PSmodu
lepath+;C:\Powershellscripts\modules
At line:1 char:37
+ $env:PSmodulepath=$env:PSmodulepath+;C:\Powershellscripts\modules
+                                     ~
You must provide a value expression following the '+' operator.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordEx
   ception
    + FullyQualifiedErrorId : ExpectedValueExpression

Any help?

npocmaka

The error comes from the powershell.The + and = are set to the variable . test with echo "%VAR%" . Just powershell starts to execute this as a command.

May be you want this?

set "VAR=$env:PSmodulepath=$env:PSmodulepath+;C:\Powershellscripts\modules"

PowerShell.exe """%VAR%"""

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to split a string by amount of characters in a batch file?

From Dev

Batch file CURL String with Spaces and Special Characters

From Dev

Use string in text file as a variable in batch

From Dev

split the string value stored in a variable by a batch file

From Dev

batch file to get partial lastmodified string to variable

From Dev

Batch file, string variable comparison, if statement

From Dev

Escaping spaces in string variable in batch file

From Dev

Batch file, check if string contains another string with special characters

From Dev

how to check if the variable contains special characters in batch file

From Dev

Batch Reading from different file, and setting each two characters as a variable

From Dev

Batch – Delete Characters in a String

From Dev

Windows Batch File - Split string with certain characters or spaces as delimiter

From Dev

Special Characters in Batch File

From Dev

Windows batch file to find variable string in a html file

From Dev

Batch file : SET variable=string doesn't work

From Dev

How to find and replace a string in %PATH% system variable with variables in a batch file?

From Dev

Using variable in sub-string operation in batch file FOR loop

From Dev

Batch How to remove file extension stored in string %variable%?

From Dev

Windows command batch file calling variable from string in nested loop

From Dev

Batch - Search text file for specified string and if found set variable to 1

From Dev

Parsing a string variable in a batch file for LAPS / ADU&C

From Dev

How to find and replace a string in %PATH% system variable with variables in a batch file?

From Dev

Delete portion of string from variable including and after pattern with batch file

From Dev

remove last characters string batch

From Dev

String replace with variable in batch

From Dev

replace special characters with % in batch file

From Dev

Pass variable into Batch file

From Dev

Variable multiplication in batch file

From Dev

Batch File not setting variable

Related Related

  1. 1

    How to split a string by amount of characters in a batch file?

  2. 2

    Batch file CURL String with Spaces and Special Characters

  3. 3

    Use string in text file as a variable in batch

  4. 4

    split the string value stored in a variable by a batch file

  5. 5

    batch file to get partial lastmodified string to variable

  6. 6

    Batch file, string variable comparison, if statement

  7. 7

    Escaping spaces in string variable in batch file

  8. 8

    Batch file, check if string contains another string with special characters

  9. 9

    how to check if the variable contains special characters in batch file

  10. 10

    Batch Reading from different file, and setting each two characters as a variable

  11. 11

    Batch – Delete Characters in a String

  12. 12

    Windows Batch File - Split string with certain characters or spaces as delimiter

  13. 13

    Special Characters in Batch File

  14. 14

    Windows batch file to find variable string in a html file

  15. 15

    Batch file : SET variable=string doesn't work

  16. 16

    How to find and replace a string in %PATH% system variable with variables in a batch file?

  17. 17

    Using variable in sub-string operation in batch file FOR loop

  18. 18

    Batch How to remove file extension stored in string %variable%?

  19. 19

    Windows command batch file calling variable from string in nested loop

  20. 20

    Batch - Search text file for specified string and if found set variable to 1

  21. 21

    Parsing a string variable in a batch file for LAPS / ADU&C

  22. 22

    How to find and replace a string in %PATH% system variable with variables in a batch file?

  23. 23

    Delete portion of string from variable including and after pattern with batch file

  24. 24

    remove last characters string batch

  25. 25

    String replace with variable in batch

  26. 26

    replace special characters with % in batch file

  27. 27

    Pass variable into Batch file

  28. 28

    Variable multiplication in batch file

  29. 29

    Batch File not setting variable

HotTag

Archive