transfer string variable

hello guys

before all the codes and stuff, a little bit of history. i study in a university where the computers are affected by the USB shortcut virus. i think its quite famous in internets and stuff. so i found out the solution to be deleting autorun.inf. however, the folders must be unhidden again, using the command "attrib -r -a -s -h".

in order to simplify these actions, i am coding a C program to automate the process. here's a part of the code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
		system("cls");
		printf("\n\n--------------------------");
		printf("\n    Attrib -R -A -S -H");
		printf("\n--------------------------\n\n");

		system("dir * /a:dh /o:n | find \"/\" > temp.txt");
		fp=fopen("temp.txt", "r");

		while (fgets(read, 100, fp)!=NULL)
		{
			printf("%s", read);
		}

		fclose(fp);
		printf("\n\nPlease key in the folder name.");
		gets(read);

		system("attrib -r -a -s -h \"%s\"", read);

		printf("\n\nDo you want to continue? (Y for yes, N for no)");
		input=_getche();
}


as you'd probably know, the problem persists in the "system("attrib -r -a -s -h \"%s\"", read);". i cannot pass a string to the "system". is there a workaround?

thanks in advance.
its okay guys. i found the solution

1
2
sprintf(new_string_variable, "command %variable_type", variable_to_pass);
system(new_string_variable);


hope this helps :)
Last edited on
Topic archived. No new replies allowed.