/* File: /home/accounts/kscott/blah.c */ /* Author: K. Scott Rowe */ /* Time-stamp: <11/26/1997 09:47:08 kscott@NICFIT> */ #include #include #include #include #define DEBUG 0 #define USAGE "Usage: instuser [-d]\n" FILE *fd ; char * command = "net config" ; char buf[80] ; char username[16] ; int i = 0 ; main() { char * path ; char * old_path ; old_path = getenv("PATH") ; /* set up a path to run sh for system() */ path = (char *) malloc(2048) ; sprintf(path, "PATH=//c/bin:%s", old_path) ; putenv(path) ; fd = popen(command, "r") ; while( strcmp(buf, "User") != 0) { fscanf(fd, "%s", buf) ; } fscanf(fd, "%s", buf) ; if(strcmp(buf, "name") == 0) { fscanf(fd, "%s", buf) ; } pclose(fd) ; while(buf[i] != NULL) { username[i] = tolower(buf[i]) ; i++ ; } #if DEBUG printf("username is %s\n", username) ; #endif if(strcmp(username, "linux") == 0) { /* system("start c:\\\\bin\\\\bootinst.pif") ; */ #if DEBUG printf("rebooting to linux...\n") ; #endif return(2) ; /* catch the error in the login batch file */ } fd = fopen("//c/tmp/profile.reg", "w") ; fprintf(fd, "REGEDIT4\n") ; fprintf(fd, "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ProfileList\\%s]\n", username) ; fprintf(fd, "\"ProfileImagePath\"=\"u:\\\\win\"\n") ; fclose(fd) ; system("//c/windows/regedit /S c:\\\\tmp\\\\profile.reg") ; return(0) ; }