Announcement

Collapse
No announcement yet.

Prevent users from closing a batch [was: logon script help]

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Prevent users from closing a batch [was: logon script help]

    I have a logon script that I am using on our computers, however, I am looking to prevent users from closing the script before entering information asked by the script. For example, I am asking for their Dept ID. Some users are just closing the .cmd script. The script is just a command window. We do not have VB or anything like that. Is there a way to prevent the user from closing the script without entering any information?

  • #2
    Re: logon script help

    A Google result for "prevent user close command prompt": http://www.computing.net/answers/pro...fil/16068.html

    So basically, no this isn't possible.

    Please can you remember to give your threads a more meaningful title in future - people can't tell from the title of this thread what you're trying to do
    Gareth Howells

    BSc (Hons), MBCS, MCP, MCDST, ICCE

    Any advice is given in good faith and without warranty.

    Please give reputation points if somebody has helped you.

    "For by now I could have stretched out my hand and struck you and your people with a plague that would have wiped you off the Earth." (Exodus 9:15) - I could kill you with my thumb.

    "Everything that lives and moves will be food for you." (Genesis 9:3) - For every animal you don't eat, I'm going to eat three.

    Comment


    • #3
      Re: logon script help

      You don't need VB software installed on any windows computers for using the Windows Scripting Host (WSH). You can simply use vbs-scripts.
      VBS-scripts are infact text-files and you can create them by yourself. The script then can be executed by users on Windows computers and used for logonscripts.

      The sample batch below uses WSH for its Inputbox function.
      The batch requires Windows XP or later, and may or may not work on Vista (not tested) computers.

      The batch also make use of a tool called CMDOW.exe for hiding the cmd-box so users are not able to terminate the batch when prompted for input.
      However, since you running the batch as logonscript you could instead of using the tool cmdow also configure the GPO and Disable "Run logon Scripts Visible"!!

      Code:
      @echo off & cls & Set "scriptpath=%~dp0"
      
      call:Set_P strInput
      
      echo The input was: %strInput%
      pause
      
      
      goto:eoInputbox
         :Set_P
         Set "r=%~1" 
         Set "CMDOW=CMDOW.exe" !!! provide full networkpath to this exe
         
         :: Hide...  (http://www.commandline.co.uk/cmdow/#params)
         "%CMDOW%" @ /HID  2>nul
      
         :: Demand for input
         Set "BoxTitle=General requirements"
         Set "BoxPrompt=Enter your Dept ID:"
         Set "TmpFile=%temp%.\TmpFile$$"
      
         :: Hybrid WSH
         Set "nLine=vbNewLine ^& vbNewLine ^&"
         >"%TmpFile%.vbs" (
           echo\With WSH ' Windows Scripting Host
           echo\  .Echo "Set %r%=" + Trim(InputBox _
           echo\    (%nLine% "%BoxPrompt%","%BoxTitle%"^)^)
           echo\End With)
      
         :Inputbox
         cscript //nologo "%TmpFile%.vbs">"%TmpFile%.cmd"
         Set "%r%=" & call "%TmpFile%.cmd"
         IF NOT DEFINED %r% (goto:Inputbox) Else (
           del "%TmpFile%.cmd" & del "%TmpFile%.vbs")
      
         :: UnHide...(optional)  (http://www.commandline.co.uk/cmdow/#params)
         "%CMDOW%" @ /VIS  2>nul
      
         Call Set "%r%=%%%r%%%"
         exit /b 0
      :eoInputbox
      If the batch does not run well on your windows version then consider to translate the complete batch to VBS.


      = EDIT =
      If CMDOW.exe is in the same folder or path as the batch then you could simply set,
      Set "CMDOW=%scriptpath%CMDOW.exe"
      (Where the variable %scriptpath% has been defined at the beginning of the batch)


      \Rems
      Last edited by Rems; 16th August 2009, 09:30.

      This posting is provided "AS IS" with no warranties, and confers no rights.

      __________________

      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts

      Comment


      • #4
        Re: logon script help

        I usually used kixtart for that...
        Marcel
        Technical Consultant
        Netherlands
        http://www.phetios.com
        http://blog.nessus.nl

        MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
        "No matter how secure, there is always the human factor."

        "Enjoy life today, tomorrow may never come."
        "If you're going through hell, keep going. ~Winston Churchill"

        Comment


        • #5
          how to stop users from closing logon script

          I have a command line logon script that is applied via Active Directory. It records the department, time, date and computer name to a csv file on a server share. We use this script to track computer usage. In order to keep funding for upgrades, repairs, etc, we have to prove that the classrooms are being used. The classrooms use shared logons. The computers are used by many people from within and outside of our organization.
          Currently, we are using sign-in sheets, but we are having trouble with people actually using the sheets. We need to show when, how long and who used the classrooms.

          The script I wrote asks a user to enter their Department while the rest is automatic. The problem I am having is that the users are just closing the window without entering anything. How can I stop this? Is there any other ways I can run this script without having to purchase any software?


          I thank you for any help I get on this.

          Comment


          • #6
            Re: how to stop users from closing logon script

            This looks to be basically the same question that you already asked in your thread posted on the 11th...
            Gareth Howells

            BSc (Hons), MBCS, MCP, MCDST, ICCE

            Any advice is given in good faith and without warranty.

            Please give reputation points if somebody has helped you.

            "For by now I could have stretched out my hand and struck you and your people with a plague that would have wiped you off the Earth." (Exodus 9:15) - I could kill you with my thumb.

            "Everything that lives and moves will be food for you." (Genesis 9:3) - For every animal you don't eat, I'm going to eat three.

            Comment


            • #7
              Re: how to stop users from closing logon script

              You could convert your .bat file to a vbs file or you could run the .bat file from a vbs file..

              Code:
              '  --- Somefile.vbs --
              Set oSh    = CreateObject("WScript.Shell")
              oSh.Run "cmd.exe /c \\servername\share\login.bat", 0, false
              The "0" tells it to run the program in the background.
              The "false" tells it to not wait for it to complete and just continue.

              Hobie

              Comment


              • #8
                Re: how to stop users from closing logon script

                Originally posted by wvdlp View Post
                I have a command line logon script that is applied via Active Directory. It records the department, time, date and computer name to a csv file on a server share. We use this script to track computer usage. In order to keep funding for upgrades, repairs, etc, we have to prove that the classrooms are being used. The classrooms use shared logons. The computers are used by many people from within and outside of our organization.
                Currently, we are using sign-in sheets, but we are having trouble with people actually using the sheets. We need to show when, how long and who used the classrooms.

                The script I wrote asks a user to enter their Department while the rest is automatic. The problem I am having is that the users are just closing the window without entering anything. How can I stop this? Is there any other ways I can run this script without having to purchase any software?


                I thank you for any help I get on this.
                => threads merged!

                @wvdlp, Please take the time to familiarise yourself with our forum rules!

                => Warning issued.

                Thank you.

                \Rems
                Last edited by Rems; 25th August 2009, 20:27.

                This posting is provided "AS IS" with no warranties, and confers no rights.

                __________________

                ** Remember to give credit where credit's due **
                and leave Reputation Points for meaningful posts

                Comment


                • #9
                  Re: Prevent users from closing a batch [was: logon script help]

                  I might have misunderstood..

                  Could you post your script? Perhaps I could convert it to a vbs file for you.

                  Hobie

                  Comment

                  Working...
                  X