•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 426,442 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,213 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 1788 | Replies: 1
![]() |
•
•
Join Date: May 2005
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
Hello guys,
Can someone gv me a Code, to a shutdown script automaticall ? i 'm a newbie, just created a billing software interface.. i created my menus.. File---->> this want i want if any of client..clicks on File menu and click on shutdown.. i want the system to shutdown immediatley and another code if the User wanna Restart the computer by click on File----> Restart. it should restart immedialty..
Lets Codes that i needed is
SHUTDOWN
RESTART
Thanks in advanced
Can someone gv me a Code, to a shutdown script automaticall ? i 'm a newbie, just created a billing software interface.. i created my menus.. File---->> this want i want if any of client..clicks on File menu and click on shutdown.. i want the system to shutdown immediatley and another code if the User wanna Restart the computer by click on File----> Restart. it should restart immedialty..
Lets Codes that i needed is
SHUTDOWN
RESTART
Thanks in advanced
•
•
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation:
Rep Power: 7
Solved Threads: 108
Method 1:
In your project, add a new standard module, and put this in it:
Then In Your File Menu, You can use it like this:
Or To Reboot The System:
Method 2:
Now, I'm not sure which version of windows you will be running this app on. An alternative method to using the API, is that if you are using a later version of windows, such as XP, and I think Win2k Also, There is a command for shutting down the system from the command line. You could use this in your app, if it will be used only on later versions of windows:
To Shutdown:
And To Reboot:
Wow, that was a bit long winded! I hope one of these methods works for you, please post and let us know how it turns out.
In your project, add a new standard module, and put this in it:
public Declare Function ExitWindowsEx Lib "user32.dll" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
public const EWX_FORCE = 4
public const EWX_LOGOFF = 0
public const EWX_POWEROFF = 8
public const EWX_REBOOT = 2
public const EWX_SHUTDOWN = 1
public function Shutdown_Windows
Dim retval As Long ' return value
retval = ExitWindowsEx(EWX_SHUTDOWN Or EWX_FORCE, 0)
Shutdown_Windows = retval
end sub
public function Reboot_Windows
Dim retval As Long ' return value
retval = ExitWindowsEx(EWX_REBOOT Or EWX_FORCE, 0)
Shutdown_Windows = retval
end subThen In Your File Menu, You can use it like this:
retval = Shutdown_Windows()
Or To Reboot The System:
retval = Reboot_Windows()
Method 2:
Now, I'm not sure which version of windows you will be running this app on. An alternative method to using the API, is that if you are using a later version of windows, such as XP, and I think Win2k Also, There is a command for shutting down the system from the command line. You could use this in your app, if it will be used only on later versions of windows:
To Shutdown:
retval = shell("shutdown.exe -s", vbhide)And To Reboot:
retval = shell("shutdown.exe -r", vbhide)Wow, that was a bit long winded! I hope one of these methods works for you, please post and let us know how it turns out.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- windows xp installation error!! pls help! (Troubleshooting Dead Machines)
- reversing long integers,, newbie,, pls. help (C)
- pls help me (Visual Basic 4 / 5 / 6)
- As a newbie, where i should start from in linux? (Getting Started and Choosing a Distro)
- Newbie needs help with Streams pls (Java)
- Book For Newbie (C++)
- can somebody pls. help me out with my HJT log.. (Viruses, Spyware and other Nasties)
- How to network two Win98 machines (Networking Hardware Configuration)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: how do i use selectionformula using 2 fields
- Next Thread: assigning arrays in VB



Linear Mode