Announcement

Collapse
No announcement yet.

How to construct a string with embedded double quotes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    Click image for larger version

Name:	testRay.png
Views:	59
Size:	3.6 KB
ID:	798517
    Like this?
    Dale

    Comment


    • #22
      Originally posted by Stuart McLachlan View Post

      What do you mean by "sending the string to DOS" ?
      Please post the line generating the "syntax error" and details of the error.
      #COMPILE EXE "E:\enable.exe"
      #DIM ALL
      $x = "netsh.exe interface set interface ""Local Area Connection"" admin=enabled"
      $eport = "Local Area Connection"

      FUNCTION PBMAIN () AS LONG
      LOCAL result AS LONG

      REM z$="netsh.exe interface set interface " + $DQ + $eport + $DQ + " admin=enabled"
      SHELL $x,0, EXIT TO result
      IF result THEN
      MSGBOX "Error" + STR$(result) + " enabling ethernet"
      END IF
      END FUNCTION

      C:\Users\Ray>netsh.exe interface set interface ""Local Area Connection"" admin=enabled
      Area is not an acceptable value for connect.
      The parameter is incorrect.


      Click image for larger version

Name:	Untitled.png
Views:	62
Size:	2.6 KB
ID:	798524

      Comment


      • #23
        Originally posted by Ray Crumrine View Post

        #COMPILE EXE "E:\enable.exe"
        #DIM ALL
        $x = "netsh.exe interface set interface ""Local Area Connection"" admin=enabled"
        $eport = "Local Area Connection"

        FUNCTION PBMAIN () AS LONG
        LOCAL result AS LONG

        REM z$="netsh.exe interface set interface " + $DQ + $eport + $DQ + " admin=enabled"
        SHELL $x,0, EXIT TO result
        IF result THEN
        MSGBOX "Error" + STR$(result) + " enabling ethernet"
        END IF
        END FUNCTION

        C:\Users\Ray>netsh.exe interface set interface ""Local Area Connection"" admin=enabled
        Area is not an acceptable value for connect.
        The parameter is incorrect.


        Click image for larger version  Name:	Untitled.png Views:	0 Size:	2.6 KB ID:	798524
        Your command line has two double quotes around Local Area Cnnection. $x doesn't (add a "? $x" line to see what you are passing to SHELL)

        What error message do you get with: netsh.exe interface set interface "Local Area Connection" admin=enabled ( ie single doublequotes)

        Comment


        • #24
          You want to enable/disable a network interface from PBWin
          The code below worked for me change ePort to the network interface you need.

          BUT this netsh command needs to be executed in eleveted rights (run as administrator) so right click your exe and run as administrator.

          Code:
          #COMPILE EXE
          #DIM ALL
          
          FUNCTION PBMAIN () AS LONG
          LOCAL result AS LONG
          LOCAL x AS STRING
          LOCAL ePort AS STRING
          ePort = "WI-FI"
          'x="netsh interface set interface name=" + $DQ + ePort + $DQ + " admin=DISABLED"
          x="netsh interface set interface name=" + $DQ + ePort + $DQ + " admin=ENABLED"
          ? x
          SHELL x ,0, EXIT TO result
          IF result THEN
          MSGBOX "Error" + STR$(result) + " enabling ethernet"
          END IF
          END FUNCTION

          Comment


          • #25
            Originally posted by Rod Macia View Post
            You want to enable/disable a network interface from PBWin
            You're the man, Rod! I think I had a space between the equal sign and the "L" [name= "Local...] and it was blowing up.

            Computers, picky. Thanks

            Comment


            • #26
              Originally posted by Ray Crumrine View Post

              You're the man, Rod! I think I had a space between the equal sign and the "name= "Local... and it was blowing up.

              Computers, picky. Thanks
              Well, that was a big waste of time
              You initially posted a question wth an apparently failing string and never told us what the "syntax error" was that you received.
              After 21 posts, you finally posted allegedly failing code which bore no resemblance to your original supposedly failing string.

              And none of your posted code has "name=" in it.

              Comment


              • #27
                ?
                Originally posted by Stuart McLachlan View Post
                Well, that was a big waste of time.
                Not really a waste of time at all. I may add a radiobox where I can select "Enable" or "Disable". I had a perfectly good batch file that worked but I wanted to spruce it up a bit. The batch file had to be run as administrator also. I must have made a typo and left the name= out of the file I was working with but that wasn't the issue. If you run your code in the debugger it will simply error out because it isn't running as admin . When I tried to debug it the debugger gave confusing results. Thanks again.

                Comment

                Working...
                X