| 1. |
Solve : Over look a > but use the >> %filename%? |
|
Answer» Hi all, long time listener, first time caller. rem @ ECHO OFF Using characters that are meaningful to the cmd shell can create all sorts of challenges, but one problem is the unbalanced quotes. Hard to tell if you want quotes in the output or not. No quotes: Code: [Select]rem @ ECHO OFF set filename="WSETTING.WFC" set wepkey="Computer_Hope.com_Rocks" ECHO ^<?xml version="1.0"?^> >> %filename% With quotes: Code: [Select]em @ ECHO OFF set filename="WSETTING.WFC" set wepkey="Computer_Hope.com_Rocks" ECHO "<?xml version="1.0"?>" >> %filename% Sorry about that, I was trying a few things earlier and left that extra quote in there. What I am trying to get accomplished is to have the bath file recreate WSETTING.WFC with the different setting each time so I can run it and add all the wireless settings with little or no manual intervention. Code: [Select]rem @ ECHO OFF set filename="WSETTING.WFC" set wepkey="Computer_Hope.com_Rocks" ECHO <?xml version="1.0"?> >> %filename% The entire code in the WSETTING.WFC I am trying to recreate is: Code: [Select]<?xml version="1.0"?> <wirelessProfile xmlns="http://www.microsoft.com/provisioning/WirelessProfile/2004"> <config> <configId>000E06EE-C94E-432A-B492-12AE01CBF3B8</configId> <configAuthorId>0B4E59B8-8317-46B2-B8C2-C46850162E6C</configAuthorId> <configAuthor>Microsoft Wireless Network Setup Wizard</configAuthor> </config> <ssid xml:space="preserve">SSID_GOES_HERE</ssid> <connectionType>ESS</connectionType> <primaryProfile> <authentication>WPAPSK</authentication> <encryption>TKIP</encryption> <networkKey xml:space="preserve">Computer_Hope.com_Rocks</networkKey> <keyProvidedAutomatically>0</keyProvidedAutomatically> <ieee802Dot1xEnabled>0</ieee802Dot1xEnabled> </primaryProfile> </wirelessProfile> The set command will accept just about any character, so by using quotes with set wepkey="Computer_Hope.com_Rocks", the quotes become part of the string. In addition each and every < and > must be escaped with the caret (^). I could have sworn there was another post in this thread that explained all that, but I'll just chalk it up to another senior moment. This should produce what you're looking for. LOOKS a bit like chicken scratch. Code: [Select]@echo off set wepkey=Computer_Hope.com_Rocks set filename="WSETTING.WFC" >>%filename% echo ^<?xml version="1.0"?^> >>%filename% echo ^<wirelessProfile xmlns="http://www.microsoft.com/provisioning/WirelessProfile/2004"^> >>%filename% echo ^<config^> >>%filename% >>%filename% echo ^<configId^>000E06EE-C94E-432A-B492-12AE01CBF3B8^</configId^> >>%filename% echo ^<configAuthorId^>0B4E59B8-8317-46B2-B8C2-C46850162E6C^</configAuthorId^> >>%filename% echo ^<configAuthor^>Microsoft Wireless Network Setup Wizard^</configAuthor^> >>%filename% echo ^</config^> >>%filename% echo ^<ssid xml:space="preserve"^>SSID_GOES_HERE^</ssid^> >>%filename% echo ^<connectionType^>ESS^</connectionType^> >>%filename% echo ^<primaryProfile^> >>%filename% echo ^<authentication^>WPAPSK^</authentication^> >>%filename% echo ^<encryption^>TKIP^</encryption^> >>%filename% echo ^<networkKey xml:space="preserve"^>%wepkey%^</networkKey^> >>%filename% echo ^<keyProvidedAutomatically^>0^</keyProvidedAutomatically^> >>%filename% echo ^<ieee802Dot1xEnabled^>0^</ieee802Dot1xEnabled^> >>%filename% echo ^</primaryProfile^> >>%filename% echo ^</wirelessProfile^> There doesn't seem to be a setting for SSID_GOES_HERE. Hope this helps or at least gives you some ideas. Question: Is this some sort of template or is there a source for the data?The SSID will vary between the many Access points, the xml code is generated by the Windows Wireless Network Setup Wizard. Thanks for the help on this. It has helped me out a lot. When I get it finished I will let you know how effective it is. Thanks Bud!!Ok, the next step that I can't figure out. This .bat will open Windows Wireless setup wizard and require the user to actually click on the "ok" button. Is there a way to make it run silent or SEND KEY strokes to the active window? The wireless setup wizard is initiated by "setupSNK.exe."Batch code cannot send keystrokes to other processes. The good news is you can write a quick VBScript which can be run from your batch file. Would need to know the title of the window which contains the OK button, whether the OK button has focus when the window opens and if not how many times you have to hit the tab key to give the OK button focus. Did you try running setupSNK.exe from the command prompt using the usual suspects for help functions? (-h, /h, /?, -?). If there is a help function, it should describe any switches that may be helpful. Yeah I tried running it from cmd with help tags trying to find more commands, but don't seem to be any. No matter what you put behind setupSNK.exe, it executes the program and does not display anymore options. First Window: The title of the window is "Wireless Network Setup Wizard." It has two option "Ok" and "Cancel", by DEFAULT "Ok" is selected. Second Window: The title of the window is "Wireless Network Setup Wizard." It only has one option "Ok" and by default it is selected. As far as writing VB, I am still struggling with .bat files. Side note: Sidewinder, I really all your help! Quote The title of the window is "Wireless Network Setup Wizard." I chose not to include the dot. If it really exists, the script can be changed easily. Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "setupSNK.exe" WScript.Sleep 1000 WshShell.AppActivate "Wireless Network Setup Wizard" WScript.Sleep 100 WshShell.SendKeys "~" WScript.Sleep 2500 WshShell.AppActivate "Wireless Network Setup Wizard" WScript.Sleep 100 WshShell.SendKeys "~" WScript.Sleep 2500 Save the script with a vbs extension, preferably in the same directory as your batch file. In your batch file place the following reference: cscript scriptname.vbs The script will run setupSNK and click the OK buttons as needed. If for any reason the OK buttons do not have focus, the script can be changed to bounce around the window until they do. Hope this helps. |
|