Thread: Need to deploy a C program .exe on domain as startup script to display some info.

  1. #1
    Registered User
    Join Date
    Jul 2013
    Posts
    24

    Need to deploy a C program .exe on domain as startup script to display some info.

    Hello to all,
    I have some requirement regarding implementing a C program .exe to implement on Domain computers as a Startup/Logon script. I created a C program which is meant to be run on domain PCs when they start/Login. This .exe program runs some DOS commands using system function, then writing output to few files. I then pick up required information from files & prints it on to a console screen. While creating this program using C compiler, it gathers all the info & prints to screen properly. It uses following commands in program:

    Code:
    reg export  "...."  "c:\\windows\\web\\wallpaper\\reg_xport.txt"
    Here "..." means some registry path e.g. HKLM\... etc.

    Code:
    systeminfo > "c:\\windows\\web\\wallpaper\\sys_info.txt"
    wmic qfe get installedon > "c:\\windows\\web\\wallpaper\\patches_date.txt"
    Two issues over here are that 'reg export' to a file and 'wmic' require admin privileges on domain PC & thus the program should carry admin rights while executing. I got this solved by putting this program to run as startup script. The program runs, creates files and removes them also(as a part of program), but shows no output on screen (from screen I mean console screen). I then created a plain "Hello" program and implemented it on few domain PCs, I guess script got executed but nothing came up on the screen. I am not sure what is happening at backend. Whether the program is able to execute only DOS commands & skip all other IF/ELSE/WHILE conditional loops. Or these are executing but PRINTF is not able to launch a console screen. Printing output to screen is must in order to pass message to users using PCs.
    Now please provide me some solution for this. Thanks...kriss332.

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    printf will not create a console to write to if one is not already attached to the process. Depending on when the program is run, this may not be possible(?). But you've already written all your info to files, so why not have another program display the info to the user? This program would NOT run as a startup script but instead as a program in the users domain (e.g., on XP you'd put it in the Startup folder).
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  3. #3
    Registered User
    Join Date
    Jul 2013
    Posts
    24
    Thanks Oogabooga. What I was planning today is that I have already written 5-6 lines to a final output.txt file (after filtering data from 5 files). If I write a .bat file using this script and at the end of this script I call that .bat file, then that batch file could print the contents of output.txt . But I don't know how to do that. Can you prrovide some help?

  4. #4
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    I don't understand what you are saying/asking.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  5. #5
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    to print text file from bat-file you can use cat utility which is available on windows as part of UnixUtils - Native Win32 ports of some GNU utilities
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  6. #6
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Quote Originally Posted by vart View Post
    to print text file from bat-file you can use cat utility which is available on windows as part of UnixUtils - Native Win32 ports of some GNU utilities
    Windows cmd.exe (the "command prompt") has the built-in "type" command that displays text files.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  7. #7
    Registered User
    Join Date
    Jul 2013
    Posts
    24
    What I have planned at last is to have another .exe to be run as a logon script (after startup script gets finished through Group Policy). Since startup scripts run with admin privileges, it will be able to run high privileged DOS commands, like- 'reg export' and 'wmic ...' , the output of all these commands will be saved to different files. These files will be opened for reading and I will pick up required data and write to a last file. The last file will have few lines only, which are required to be printed. Then another .exe will run at logon(as local logon script, not through Group Policy), which will simply print the contents of last file. Same way as oogabooga said. I'll try to finish it within these two holidays and on monday I'll give it a try & let you all know.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 05-02-2012, 04:17 PM
  2. startup script to launch .swf file
    By cDev in forum C Programming
    Replies: 5
    Last Post: 07-26-2006, 01:29 PM
  3. Display Two Dimen.. Info Help?
    By Dilmerv in forum C++ Programming
    Replies: 8
    Last Post: 04-28-2006, 02:25 PM
  4. Startup using STARTUP folder method for winXP & win98
    By hanhao in forum Windows Programming
    Replies: 2
    Last Post: 05-26-2005, 04:59 AM
  5. How to deploy an application
    By axr0284 in forum Windows Programming
    Replies: 0
    Last Post: 04-04-2005, 08:05 AM