如下程序解决了用户自己升级msde的sp3时要配置参数,输入SQL密码等一系列问题,既保证了SQL密码的安全性,又简便了用户的升级操作(只要把程序编译好放在SP3的目录里双击就可以了)
// update3.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include <process.h>
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
HANDLE consoleStdout,consoleStdin;
::AllocConsole();
consoleStdin=::GetStdHandle(STD_INPUT_HANDLE);
consoleStdout=::GetStdHandle(STD_OUTPUT_HANDLE);
if(consoleStdin==consoleStdout)
return 1;
char consoleName[256];
::GetConsoleTitle(consoleName,256);
HWND hwnd=::FindWindow("ConsoleWindowClass",consoleName);
if(hwnd)
{
::SendMessage(hwnd,WM_SYSCOMMAND,(WPARAM)SC_MINIMIZE,0);
::ShowWindow(hwnd,SW_HIDE);
}
system("net stop MSSQL$ERP");
system("setup /upgradesp sqlrun INSTANCENAME=实例名 SECURITYMODE=SQL UPGRADEUSER=sa UPGRADEPWD=密码 DISABLENETWORKPROTOCOLS=1");
system("net start MSSQL$ERP");
::MessageBox(NULL,"所有操作已结束","msde升级sp3",MB_OK);
return 0;
}