Tech ARP Forums

Go Back   Tech ARP Forums > Software Discussion > General Software
Register
FAQ Members List Calendar Arcade Mark Forums Read

Google Web www.techarp.com forums.techarp.com

General Software This is the forum for general discussions about software.

Reply
 
LinkBack Thread Tools
Old 31st Jan 2007, 11:45 AM   #1 (permalink)
Administrator!
 
Dashken's Avatar
 
Join Date: 21 Apr 2003
Location: Penang
Posts: 29,820
Reputation: 2162
Dashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond repute
Rep Power: 56
Default Reboot & sleep loop in Windows Vista

Well, I want to start to pick up on programming again.

I wish to create a tool for stress testing Windows Vista system through running reboot or sleep in a definite loop which will increase a counter upon each reboot/sleep&wakeup completed.

Anyway I can do that? I hope someone can point me to somewhere for more info.

Thanks.
__________________
| Intel Core 2 Duo E6850 @ 3.2Ghz | ASUS P5B-E Plus | G.SKILL 2x1GB DDR2 800 | 6 HDDs (2TB+ only ) | NVIDIA GeForce 7600GT | Dell E248WFP 24" Widescreen |


Blog : Dashken's I-Blog
Gallery : Dashken's I-Paintings
Dashken is offline   Reply With Quote
SPONSOR

Old 31st Jan 2007, 11:50 AM   #2 (permalink)
shutdown -h now
 
hyper_raider's Avatar
 
Join Date: 15 Aug 2003
Location: in front of my pc
Posts: 6,002
Reputation: 1078
hyper_raider has much to be proud ofhyper_raider has much to be proud ofhyper_raider has much to be proud ofhyper_raider has much to be proud ofhyper_raider has much to be proud ofhyper_raider has much to be proud ofhyper_raider has much to be proud ofhyper_raider has much to be proud of
Rep Power: 22
Default

I think you can write a batch script of a vb script that does that, and also make it a part of you boot up sequence <-- not such a good idea cos you wont be able to boot up to windows without getting rid of that script from the run level
__________________
"God does not play dice with the universe."
- Albert Einstein (1879-1955)
http://edward-lim.blogspot.com
hyper_raider is offline   Reply With Quote
Old 31st Jan 2007, 02:19 PM   #3 (permalink)
ARP Webmaster
 
peaz's Avatar
 
Join Date: 13 Oct 2002
Location: http://atpeaz.placidthoughts.com/
Posts: 8,515
Reputation: 1673
peaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant future
Rep Power: 31
Default

Hmmm sounds like you'd need to invoke the windows API to get it to restart. increment counters should not be a problem. it will just be reading and writing to a text file. that's the simplest method to keep track of the number of runs.

once u program this application, run it as a startup program.

As to where and how, Hmm i can try to find it but you'd probably have to refer to the latest MSDN for Vista's APIs.
peaz is offline   Reply With Quote
Old 31st Jan 2007, 02:36 PM   #4 (permalink)
ARP Webmaster
 
peaz's Avatar
 
Join Date: 13 Oct 2002
Location: http://atpeaz.placidthoughts.com/
Posts: 8,515
Reputation: 1673
peaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant futurepeaz has a brilliant future
Rep Power: 31
Default

looks like the API u need to invoke is ExitWindowsEx()
http://homepages.tesco.net/J.deBoyne...n-process.html

http://msdn2.microsoft.com/en-gb/library/aa376868.aspx
A sample on VB.NET
http://vbnet.mvps.org/index.html?cod...twindowsex.htm
peaz is offline   Reply With Quote
Old 31st Jan 2007, 05:58 PM   #5 (permalink)
I'm a regular
 
Join Date: 3 Mar 2005
Posts: 471
Reputation: 142
jamotto will become famous soon enoughjamotto will become famous soon enough
Rep Power: 5
Default

I think this should do most of what you want to do.

Code:
#include <windows.h>

/*------------------------------------------------------------------------
 Procedure:     SystemReboot ID:1
 Purpose:       The SystemReboot function either logs off the
                current user, shuts down the system, or shuts down
                and restarts the system. This is layer function
                to ExitWindowsEx. It ask necesory privilege under
                WinNT.
 Input:         Mode - Specifies the type of shutdown.

                EWX_LOGOFF Shuts down all processes running in the
                security context of the process that called the
                ExitWindowsEx function. Then it logs the user off.

                EWX_POWEROFF Shuts down the system and turns off the
                power. The system must support the power-off feature.

                EWX_REBOOT Shuts down the system and then restarts
                the system.

                EWX_SHUTDOWN Shuts down the system to a point at
                which it is safe to turn off the power. All file
                buffers have been flushed to disk, and all running
                processes have stopped. If the system supports the
                power-off feature, the power is also turned off.

                EWX_FORCE Forces processes to terminate. When this
                flag is set, the system does not send the
                WM_QUERYENDSESSION and WM_ENDSESSION messages. This
                can cause the applications to lose data. Therefore,
                you should only use this flag in an emergency.
 Output:
 Errors:        If the function succeeds, the return value is
                nonzero. If the function fails, the return value is
                zero. To get extended error information, call
                GetLastError.
------------------------------------------------------------------------*/
BOOL WINAPI SystemReboot(UINT mode)
{
	BOOL ret;
	OSVERSIONINFO vi;

	vi.dwOSVersionInfoSize = sizeof(vi);
	GetVersionEx (&vi);

	// Do we have Windows NT/W2K/XP
	if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT)
	{
		HANDLE hToken;
		TOKEN_PRIVILEGES tp;

		ret = FALSE;
		// open access privilege list.
		if (OpenProcessToken (GetCurrentProcess (),
			TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
		{
			tp.PrivilegeCount = 1; // one privilege to set
			// Ask the "shutdown" LUID
			LookupPrivilegeValue (NULL, SE_SHUTDOWN_NAME,
				&tp.Privileges[0].Luid);
			// enable it
			tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
			// Get the shutdown privilege for this process.
			AdjustTokenPrivileges (hToken, FALSE, &tp, 0, NULL, 0);
			// Cannot test the return value of AdjustTokenPrivileges.
			ret = (GetLastError () == ERROR_SUCCESS);
		}
	}
	else
	    ret = TRUE;

	return (ret ? ExitWindowsEx (mode, 0) : FALSE);
}
jamotto is offline   Reply With Quote
Old 2nd Feb 2007, 10:11 AM   #6 (permalink)
Administrator!
 
Dashken's Avatar
 
Join Date: 21 Apr 2003
Location: Penang
Posts: 29,820
Reputation: 2162
Dashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond reputeDashken has a reputation beyond repute
Rep Power: 56
Default

Wow... thanks everyone! Appreciate it. Now, I have to dig deep and find any programming skills that I've still got left.
__________________
| Intel Core 2 Duo E6850 @ 3.2Ghz | ASUS P5B-E Plus | G.SKILL 2x1GB DDR2 800 | 6 HDDs (2TB+ only ) | NVIDIA GeForce 7600GT | Dell E248WFP 24" Widescreen |


Blog : Dashken's I-Blog
Gallery : Dashken's I-Paintings
Dashken is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
NVIDIA PRODUCTS BOLSTER GRAPHICS CAPABILITIES OF MICROSOFT WINDOWS VISTA! Dashken News 0 11th Jan 2006 07:21 PM
Microsoft Advices to Avoid Integrated Graphics Cores for Windows Vista! Dashken News 16 9th Aug 2005 01:17 PM
First potential virus risk for Windows Vista found! Dashken News 0 5th Aug 2005 03:55 PM


All times are GMT +8. The time now is 01:30 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 1998-2007 Tech ARP. All rights reserved.