Sourcesafe command line

MS SourceSafe supports command line to perform source control. We can start a command shell from Windows and
type VSS commands or run a batch file.
We need to set two user environment variables:
  • PATH: We need to add the VSS\win32 executible path to the default path list.  For example PATH=%PATH%;c:\Program Files\vss\win32.
  • SSDIR: Specifies the location of the SRCSAFE.INI file for the VSS database that you want to connect to. It can be local folder, UNC name, or mapped drive and folder. For example SET SSDIR=\\MySrcServer\Sourcesafe\. If you run the source safe commands in a batch, you can setup the environment variables in your batch file.
All source safe commands has the following syntax:
SS comand [items] [options].
command: source safe commands. E.g. Checkout, checkin, get, about, Add, Create etc
items: vss items, e.g. project, files etc
options: Vss options.
 
Check out files:
ss Checkout VSSfiles [-C] [-F] [-G] [-H] [-I-] [-N] [-O] [-R] [-V] [-Y] [-?]
The command checkout one or more files from a project to current folder
  • VSSfiles inlcudes project path and file name
  • -Y: to specify the login and/or password of sourcesafe database. E.g.; -YAdmin; -YAdmin,MyPass
  • -I-: There are a number of circumstances when VSS commands ask for input from the user (for example, warnings containing Yes or No questions). -I option is to supress all the questions. E.g. -I-N, to answer N for all questions. The option is very useful in a bacth file
  • -C: It’s used for any command that requires a comment. E.g.: -CAuto Check out, for all items use this comment. -C-, no comment for all items
    For other options, please reference http://msdn.microsoft.com/library/default.asp?url=/library/en-us/guides/html/vsgrfcmdline_switchc.asp
E.g.:
To check out the file main.c in $/MyProjects/TestProject
SS Checkout $/MyProjects/TestProject/Main.c
The following batch will check out all files of project $/Server Applications/Database to folder G:\MyPorject\TestProject\
REM Set the enviroment variable for sourcesafe database directory
SET SSDIR=\\MyServer\sourcesafe\
SET PROJECT="$/Server Applications/Database"
SET WORKINGFOLDER=G:\MyPorject\TestProject\
REM Change current drive and folder to the script folder
REM Scripts will be checked out into this folder
CD/d %WORKINGFOLDER%
REM Check out all files of the project without getting a local copy. Answer all questions to N (No)
SS Checkout %PROJECT% -C"Auto check out by SQL script builder" -YAdmin -I-N
SET PROJECT=
SET SSDIR=
Check in files:
ss Checkin VSS files [-C] [-H] [-I-] [-K] [-N] [-O] [-P[project]] [-R] [-W] [-Y] [-?]
Check in the changes made to the checked out files of a project to the same or different project.
E.g.
To check in Main.c of project $/MyProjects/TestProject
SS Checkin $/MyProjects/TestProject/Main.c
To check in all c files(*.c) of project $/MyProjects/TestProject
SS Checkin $/MyProjects/TestProject/*.c
The following batch will check out all the files of project $/Server Applications/Database, but dose not get a local copy of the file to the folder (-G-), then check in all the files from checked out location:
REM Set the enviroment variable for sourcesafe database directory
SET
SSDIR=\\MyServer\sourcesafe\
SET PROJECT="$/Server Applications/Database"
SET WORKINGFOLDER=G:\MyPorject\TestProject\
REM Change current folder to the script folder
REM Scripts will be checked out into this folder
CD/d %WORKINGFOLDER%
REM Check out all files of the project without getting a local copy
SS Checkout %PROJECT% -C"Auto check out by SQL script builder" -YAdmin -G- -I-N
REM Check in all files of the project
SS Checkin %PROJECT%/* -C"Auto check in by SQL script builder" -YAdmin -I-N
SET PROJECT=
SET SSDIR=
Advertisements
This entry was posted in Other Programming. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s