Click here to Skip to main content
15,903,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I just want to create a program to open specific webpage.
For example open the website below:
http://xxxx/cgi-bin/main-cgi?json=%7b%2cmd%2%3a%2c%2bEnabled%2%3a%7d
xxxx means something you need to enter

What I have tried:

1.I have tried in bat.
@set /p ip=please enter ip:

@start explorer.exe "http://%ip%/cgi-bin/main-cgi?json=%%7b%22cmd%22%3a654%2c%22bEnabled%22%3a1%7d"

@exit

2.I have tried in C++
#include<stdio.h>
#include<windows.h>
int main() {
	ShellExecute(NULL, "open", "http://IP/cgi-bin/main-cgi?json=%7b%%22cmd%22%3a654%2c%22bEnabled%22%3a1%7d", NULL, NULL, SW_HIDE);
	return 0;
}

But as you know, % don't show as a character.
What can I do? Please help.
Posted
Updated 1-May-19 1:37am

1 solution

Percent is a "special character" in url / query strings: the following data is taken as a character.
Double up on your '%' characters:
explorer.exe "http://codeproject.com/cgi-bin/main-cgi?json=%%7b%%%%22cmd%%22%%3a654%%2c%%22bEnabled%%22%%3a1%%7d"
and they wioll pass through as percent characters.
 
Share this answer
 
Comments
Armstchi 2-May-19 11:04am    
Thanks for your help, but it still not work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900