Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

Disable the Close Program "X" button on a command prompt

- - - - -

  • This topic is locked This topic is locked
10 replies to this topic

#1
dunkie12

dunkie12

    Newbie

  • Member
  • 17 posts
  • Joined 15-January 07
Hi all,
As part of the startup of our SOE PC's for the first time, I have automatic login enabled for one single login. When the machine logs in, it runs a command script that refreshes the domain group policy, adds an account into the local administrator group and imports a registry key that is cleared by sysprep. The script then uses the sleep tool to wait 60 seconds before rebooting the machine.
I'm wanting to disable the close program button for this script so our users cannot kill the script and gain access to windows. Does anyone know of a way to disable the Close Program or "X" button on a command prompt window please?


How to remove advertisement from MSFN

#2
infiniti25

infiniti25

    Junior

  • Member
  • Pip
  • 97 posts
  • Joined 03-December 08
A quick google search revealed the following method creating a program in VB6. I guess you could load this up in your script as the first thing it runs.

here is a simple example that will find the command prompt window by it's window caption and disable the "x"


Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal _
wFlags As Long) As Long
Private Const MF_BYPOSITION = &H400


Private Sub Command1_Click()
Dim cmdHwnd As Long, SysMenu As Long, Res As Long
cmdHwnd = FindWindow(vbNullString, "C:\WINDOWS\system32\cmd.exe")
If cmdHwnd <> 0 Then
SysMenu = GetSystemMenu(cmdHwnd, 0)
Res = RemoveMenu(SysMenu, 6, MF_BYPOSITION)
SetForegroundWindow cmdHwnd
End If
End Sub

Source: http://www.experts-e...Q_21805315.html

I have access to Visual Studio somewhere so I could attempt to build this for you at somepoint if you are not able to, just PM me if you want anything like this.

Edited by infiniti25, 04 December 2008 - 07:32 AM.

  • iinfarlina likes this
{GA-P35-DQ6, Watercooled G0 Q6600, 8GB OCZ, 8800GT 1GB Silent}
{Vista Ultimate x64, VirtualBox (Windows XP SP3, Debian Etch, Cent-OS)}

#3
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,540 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

From what you've said there is no need to have a visible window showing since there is no user interaction required. Therefore you can simply prevent the window from showing!

There are many ways of doing that, third party 'hide' utilities or vbscripting being the most common methods.

#4
dunkie12

dunkie12

    Newbie

  • Member
  • 17 posts
  • Joined 15-January 07
Thanks for your replies - I guess I forgot to mention the command prompt also displays a message that says "Please wait while your antivirus software is updated".
Whilst this message isn't essential it's nice to have it there so the user's don't panic at not being able to use the desktop or interact with their PC.
The utility that regenerates the SID's in our antivirus is also closeable so I guess it doesn't make much difference...

Thanks for your suggestions!

#5
iinfarlina

iinfarlina
  • Member
  • 3 posts
  • Joined 15-June 14
  • OS:none specified
  • Country: Country Flag

please, i have try in vb express 2010 and not good result about close (x) command prompt

please anybody can help me?



#6
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,562 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

please, i have try in vb express 2010 and not good result about close (x) command prompt

please anybody can help me?

Would this do?

http://www.donationc...ex.html#NoClose

 

jaclaz



#7
iinfarlina

iinfarlina
  • Member
  • 3 posts
  • Joined 15-June 14
  • OS:none specified
  • Country: Country Flag
jaclaz, i cant acsses your link, i try but i cant, so

#8
bphlpt

bphlpt

    MSFN Addict

  • Member
  • PipPipPipPipPipPipPip
  • 1,798 posts
  • Joined 12-May 07
  • OS:none specified
  • Country: Country Flag

jaclaz, i cant acsses your link, i try but i cant, so

 

It worked for me just now.

 

Cheers and Regards


Posted Image


#9
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,562 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag
What do you mean cannot access? :unsure:
 
What do you get?
 
Like a 404, a suffusion of yellow, your PC shuts down :w00t: or explodes :ph34r:, what?
The links:
http://www.donationcoder.com/
http://www.donationc...mmel/index.html
http://www.donationc...ex.html#NoClose
 

Disable the Close button (X) of selected windows.

Features:
- Press Ctrl+1 to Enable or Disable the Close button of the active window.
- Press Ctrl+2 to Add a rule.
- Automatic enabling and disabling of close buttons on program start and stop, and on window creation.
- Change hotkeys and automation options.

Changes:
- 2006.05.02 - v1.1: Corrected a settings error, changed the about dialog.

Thanks to mouser at DonationCoder Forum for the idea!

all work here, the direct link to the download is:
http://www.donationc...ose/NoClose.exe
but if the above ones don't work, possibly this one would not also.
 
jaclaz

#10
iinfarlina

iinfarlina
  • Member
  • 3 posts
  • Joined 15-June 14
  • OS:none specified
  • Country: Country Flag
ohh jaclaz, thank you for helped me. its amazing tool for me, but my teacher just want it in vb.net language :(

#11
dencorso

dencorso

    Iuvat plus qui nihil obstat

  • Supervisor
  • 5,932 posts
  • Joined 07-April 07
  • OS:98SE
  • Country: Country Flag

Donator

... but my teacher just want it in vb.net language.

What part of "help with academic material, such as assignments, is not permitted on MSFN" (Rule #2c) did you fail to understand, iinfarlina? :angry:






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users