dunkie12 Posted November 21, 2008 Posted November 21, 2008 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?
infiniti25 Posted December 4, 2008 Posted December 4, 2008 (edited) 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 LongPrivate Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As LongPrivate Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal _ wFlags As Long) As LongPrivate Const MF_BYPOSITION = &H400Private Sub Command1_Click()Dim cmdHwnd As Long, SysMenu As Long, Res As LongcmdHwnd = FindWindow(vbNullString, "C:\WINDOWS\system32\cmd.exe")If cmdHwnd <> 0 Then SysMenu = GetSystemMenu(cmdHwnd, 0) Res = RemoveMenu(SysMenu, 6, MF_BYPOSITION) SetForegroundWindow cmdHwndEnd IfEnd SubSource: http://www.experts-exchange.com/Programmin...Q_21805315.htmlI 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 December 4, 2008 by infiniti25 1
Yzöwl Posted December 4, 2008 Posted December 4, 2008 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.
dunkie12 Posted December 4, 2008 Author Posted December 4, 2008 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!
iinfarlina Posted June 16, 2014 Posted June 16, 2014 please, i have try in vb express 2010 and not good result about close (x) command promptplease anybody can help me?
jaclaz Posted June 16, 2014 Posted June 16, 2014 please, i have try in vb express 2010 and not good result about close (x) command promptplease anybody can help me?Would this do?http://www.donationcoder.com/Software/Skrommel/index.html#NoClose jaclaz
iinfarlina Posted June 20, 2014 Posted June 20, 2014 jaclaz, i cant acsses your link, i try but i cant, so
bphlpt Posted June 20, 2014 Posted June 20, 2014 jaclaz, i cant acsses your link, i try but i cant, so It worked for me just now. Cheers and Regards
jaclaz Posted June 20, 2014 Posted June 20, 2014 What do you mean cannot access? What do you get? Like a 404, a suffusion of yellow, your PC shuts down or explodes , what? The links: http://www.donationcoder.com/ http://www.donationcoder.com/Software/Skrommel/index.html http://www.donationcoder.com/Software/Skrommel/index.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.donationcoder.com/Software/Skrommel/NoClose/NoClose.exe but if the above ones don't work, possibly this one would not also. jaclaz
iinfarlina Posted June 26, 2014 Posted June 26, 2014 ohh jaclaz, thank you for helped me. its amazing tool for me, but my teacher just want it in vb.net language
dencorso Posted June 26, 2014 Posted June 26, 2014 ... 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?
Recommended Posts