DumpZ
Mar 28 2004, 12:08 PM
I creating a SQL Secure.bat for my test server. because i try everything on that thing i need to reistall it allot.
So i want to create a batch file which secures it. but i m having a few problems.
I want to change the blank sa password on the sql.
but if i do this in the batch file OSQL -U sa -Q "sp_password NULL, 'newpass', 'sa'"
then i get prompted for my original password which is blank so how do i give a blank password in a batch file.
And is there and environment variable for Program Files? Like there is for the windows dir (%systemroot%)
aapje
Mar 28 2004, 12:34 PM
sp_password NULL, "yourpass", sa i belive
DumpZ
Mar 28 2004, 03:56 PM
Yeah but after that command is still get prompted for they original pass
M4UZi
Mar 28 2004, 08:00 PM
hi DumpZ
this here should work with BLANk pass: -------------------------------------------------------------------------- osql -Usa -P -Q"Exec sp_password NULL,'NEWPASS','sa'" -n --------------------------------------------------------------------------
paste it in a batch file, and execute it in the mssql folder where the osql is.
DumpZ
Mar 28 2004, 09:27 PM
Thanks man i'll try that!
r1dg3d
Mar 30 2004, 01:51 PM
| QUOTE (DumpZ @ Mar 28 2004, 12:08 PM) | | And is there and environment variable for Program Files? Like there is for the windows dir (%systemroot%) |
good question, anyone know?
FiNaLBeTa
Mar 30 2004, 02:15 PM
On my system the path variable holds c:/program files. meaning anything can be executed right from the command line, but the is no special windows variable to go to that dir that i know of.
The thing is, the reason the is a %systemroot% var is that you have c:/windows and c:/winnt.
program files is always the same, so it's useless anyways.
r1dg3d
Mar 30 2004, 08:02 PM
| QUOTE (FiNaLBeTa @ Mar 30 2004, 02:15 PM) | On my system the path variable holds c:/program files. meaning anything can be executed right from the command line, but the is no special windows variable to go to that dir that i know of.
The thing is, the reason the is a %systemroot% var is that you have c:/windows and c:/winnt.
program files is always the same, so it's useless anyways. |
true :\ thx
DumpZ
Mar 30 2004, 08:40 PM
True, but if the system is in another language, like in german it is programme instead of program files
BlaStA
Mar 30 2004, 09:10 PM
C:\Dokumente und Einstellungen\Administrator>echo %programfiles% C:\Programme
Just type set in the command prompt to see all environment variables and their values.
tweakz20
Mar 30 2004, 09:57 PM
type "SET" and you'll see all the enviormental variables... yes, the program files is %ProgramFiles% and it goes to C:\Program Files (unless you change the default...) also, if you want to see just variables in one certain letter... set a (where a is, whatever letter you want) also to be helpfull on it... here's some they don't show %time% = whatever time it is now, how to make batch files do something at a specific time  %date% = i think you can figure it out. %random% = generates random numbers
daguilar01
Mar 30 2004, 10:04 PM
| QUOTE (BlaStA @ Mar 30 2004, 02:10 PM) | C:\Dokumente und Einstellungen\Administrator>echo %programfiles% C:\Programme
Just type set in the command prompt to see all environment variables and their values. |
| CODE | C:\Documents and Settings\Daguilar>echo %programfiles% C:\Program Files |
same here, im guessing what youre looking for is "%programfiles%"
DumpZ
Mar 31 2004, 01:34 PM
Thanks you all this is all very helpfull.
I there also a possibility to delete the batch file after it is completed. because when i add del sql.bat at the end of the batch file it will not work. i tried calling another batch file but that didn't workt either
BlaStA
Mar 31 2004, 01:52 PM
Try "del %0", works for me.
evoLv3
Mar 31 2004, 04:36 PM
u can define additional "systemroot" dirs, to execute progs and batches directly. just go in sys-manegament, advanced and then click environment variables. then edit the PATH box and set your own systemroot dir.
jubbly
Apr 1 2004, 08:56 AM
Thanx loads tweakz20 I was looking for info on that to see what environment variables set
Reckless
Apr 15 2004, 06:27 AM
Can someone help me figure out how to make this bat file
I have ips in a txt file ip.txt like
127.0.0.1 127.0.0.2
When i run the batch , I want to make the output such that it creates a new txt file/modifies the same ip.txt and adds a string at the beginning of each ip ,like
Hello 127.0.0.1 Hello 127.0.0.2
I"ve tried using echo but , it just starts it off in a newline.
Nee suggestions ?
Thx
BlaStA
Apr 15 2004, 06:42 AM
FOR /F %i IN (ip.txt) DO echo Hello %i>ip2.txt copy /Y ip2.txt ip.txt
To put this in a batch, use %% instead of %.
Reckless
Apr 15 2004, 06:48 AM
Thanks Blasta
w0mbat
Apr 15 2004, 06:49 AM
| QUOTE |
To change the password from the command line on MSSQL Server or MSDE: 1. Open a command shell by selecting "Start"-->"Run...", and typing "cmd.exe" in the "Run" dialog box. 2. Change to the directory in which the MSSQL or MSDE utilities are stored (this is usually C:\MSDE\binn, C:\MSSQL7\binn, etc., but YMMV). 3. Issue the following command where <newpassword> is the password you have chosen: osql -U sa -P "" -Q "sp_password NULL,<newpassword>,sa"
|
So when you want to change from "oldpass" to "anotherpass" for example, just do:
osql -U sa -P "oldpass" -Q "sp_password oldpass,anotherpass,sa"
Reckless
Apr 16 2004, 06:09 AM
| QUOTE (BlaStA @ Apr 15 2004, 06:42 AM) | FOR /F %i IN (ip.txt) DO echo Hello %i>ip2.txt copy /Y ip2.txt ip.txt
To put this in a batch, use %% instead of %. |
Thanks Fer the code works great .. Just a typo in that
FOR /F %i IN (ip.txt) DO echo Hello %i>>ip2.txt
left out a ">" .
>> Echos the string for the entire list.
> adds the string only for the last one in the list. the other stuff gets overwritten i guess.
Thx for the code
BlaStA
Apr 16 2004, 07:26 AM
| QUOTE (Reckless @ Apr 16 2004, 08:09 AM) | left out a ">" .
>> Echos the string for the entire list.
> adds the string only for the last one in the list. the other stuff gets overwritten i guess.
Thx for the code |
Yeah, you're right, sorry for the fault and thanks for your correction.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
|