473,396 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Executing a reboot command from SQL

Here is the block of the sproc that I?ve created. All lines execute
fine except for the ?exec master..xp_cmdshell @reboottc?. In order to
make this work from the query analyzer I had to set the MSSQLSERVER
service to have the same credentials as the thin clients we are trying
to shut down, that means the service is running as an Administrator on
the sql server with the same u/p as administrator on thin clients.
declare @RoomNumber varchar(6) -- for testing

set @RoomNumber = '1144' -- for testing

DECLARE @RoomIP varchar(15), @RebootTC
varchar(120), @shutdownStart varchar(20), @shutdownEnd varchar(85)

-- @ShutDownStart and @ShutDownEnd will be used
with the @RoomIP to build the shutdown command sent to the thin
clients

SET @ShutDownStart = 'shutdown -r -f -m \\'

SET @ShutDownEnd = ' -t 5 -c "Mandatory
iConnect Reboot issued during guest check in/out process"'

SELECT @RoomIP = IP FROM Rooms WHERE
RoomNumber = cast(@RoomNumber AS INT)

SET @RebootTC = @ShutDownStart + @RoomIP +
@ShutDownEnd

-- print @RebootTC -- for testing

-- @RebootTC ends up looking like the line below based on the
@RoomNumber

-- shutdown -r -f -m \\172.18.16.103 -t 5 -c "Mandatory iConnect
Reboot issued during guest check in/out process?

-- Also the command below runs correctly when executed from SQL Query
Analyzer
EXEC master..xp_cmdshell @RebootTC
Jul 20 '05 #1
1 2221

"Steve Duke" <st*******@Comcast.net> wrote in message
news:d3**************************@posting.google.c om...
Here is the block of the sproc that I?ve created. All lines execute
fine except for the ?exec master..xp_cmdshell @reboottc?. In order to
make this work from the query analyzer I had to set the MSSQLSERVER
service to have the same credentials as the thin clients we are trying
to shut down, that means the service is running as an Administrator on
the sql server with the same u/p as administrator on thin clients.


<snip>

I admit that I haven't looked at your code in detail, but all code executes
on the server, so any xp_cmdshell commands execute as the server, not the
client. That means that if you want a command to shut down servers or
workstations, then you'll have to give those permissions to the MSSQL or SQL
Server Agent proxy service account (see "xp_cmdshell" in Books Online). You
might want to look at doing this outside MSSQL, unless you have a compelling
reason to do it in the database.

Simon
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Stephane Dalpe | last post by:
Hi all, I just want to know why when I'm installing jdk sometimes ask me to reboot and sometimes he don't. As part of our installation, we launch the jdk installation if it's not already...
0
by: Nick Coghlan | last post by:
Anyone playing with the CPython interpreter's new command line switch might have noticed that it only works with top-level modules (i.e. scripts that are directly on sys.path). If the script is...
15
by: Nick Coghlan | last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path. Trying to use it with modules inside packages will fail with a "Module not found" error. This PEP aims to fix that...
1
by: Steve Duke | last post by:
Here is the block of the sproc that I?ve created. All lines execute fine except for the ?exec master..xp_cmdshell @reboottc?. In order to make this work from the query analyzer I had to set the...
2
by: innesm | last post by:
Hi, Although I havent been able to find any documentation to confirm it, it looks like any change to a windows local group's membership is only reflected in the group editing UI (and the...
4
by: martijn | last post by:
Hi, I am trying to create an application for our servicedesk. With this application the servicedesk members, can remotely image an workstation. What am looking for is a command line that...
4
by: Urs Vogel | last post by:
Hi I deploy a Windows Service which requires a reboot after setup. The setup project, however, does not automatically recognize this requirement.How do I force a reboot (or set a reboot...
3
by: lukecooley | last post by:
I am new to coding in vb.net and I am trying to add a registry value in the runonce key. The key is added correctly, as I can see it when going directly into the registry after executing my code,...
3
by: iamsiju | last post by:
Hi, I am facing a problem with the Perl Telnet Object. My Telnet Object hangs just after issueing reboot command on the remote host. Please help me who faced this problem !!! Thanks in...
2
by: =?Utf-8?B?VHJhY2tz?= | last post by:
When I run my setup of a vb.net app made in VS2005 and setup made with the setup wizard and then modified in the ide, The .net 2 setup runs and installs and then asks to reboot. If you answer ok...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.