Sign in to follow this  
Followers 0
cookiemonster

cmd with varible

24 posts in this topic

Hey all,

 

been having a bit of trouble, I need to run a cmd prompt then the following (note: line four needs to use the varible: $time)

 

set path=C:Program FilesMicrosoft Visual StudioVSSwin32

set ssdir=buttonhomeVSS database

SET PROJECT= $/myfiles/

ss Add C:locks$time

Have you got any ideas, ive tried a couple of cmd ways but it starts entering the first line before cmd's even loaded so it only gets the second half of the line, and I dont know how to parse the variable into this.

Share this post


Link to post
Share on other sites



You can set environment variables with the EnvSet command, no need to use a command prompt for that. What is SS and what is it supposed to be doing?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Why not write to a batch file, execute it, then delete the batch file. Rather simple I think.

Share this post


Link to post
Share on other sites

Or you could all write in a single line:

$sCmd = "set path=C:\Program Files\Microsoft Visual Studio\VSS\win32 && set ssdir=\\button\home\VSS database && SET PROJECT= $/myfiles/ && ss Add C:\locks\" & $time
Run(@ComSpec & " /c " & $sCmd, "", @SW_HIDE)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

It should be adding a new file to microsoft visual sourcesafe, water I tried your line and it runs and finishes but nothing in VSS, so I changed it to the following in hope that I would then be able to see the cmd window without it flashing off my screen to see what the error is (I suspect its expecting some user intervention like entering comments about the file its adding) however it still flashed off the screen

$sCmd = "set path=C:\Program Files\Microsoft Visual Studio\VSS\win32 && set ssdir=\\button\home\VSS database && SET PROJECT= $/Smartbooker && ss Add C:\hello.c"
Run(@ComSpec & " /c " & $sCmd, "", @SW_SHOW)

Share this post


Link to post
Share on other sites

Change "/C" (close) to "/K" (keep) in the Run statement.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Ah one of the errors ive seen before when working out the right cmd's to use

'ss' is not recognized as an internal or external command,
operable program or batch file.

this is coming up because it doesnt know the correct path

set path=C:\Program Files\Microsoft Visual Studio\VSS\win32

it doesnt seem to be running the set path line, because this is correct, I added a pause before and after it and all I see is:

Press any key to continue . . .
Press any key to continue . . .

Any ideas why it isnt passing through the set path line, I think its also missing the ssdir line too

Share this post


Link to post
Share on other sites

Try this and check if Path is correctly set:

$sCmd = "set path=C:\Program Files\Microsoft Visual Studio\VSS\win32 && set"
Run(@ComSpec & " /k " & $sCmd, "", @SW_SHOW)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

yeh its got 

Path=C:\Program Files\Microsoft Visual Studio\VSS\win32

Share this post


Link to post
Share on other sites

right this is weird,

so I know its set the path:

Path=C:\Program Files\Microsoft Visual Studio\VSS\win32

I know its set the dir:

ssdir=\\button\home\VSS database

I know its set the project:

PROJECT= $/Smartbooker

but when it trys to add the file:

ss Add C:\hello.c

I get :

'ss' is not recognized as an internal or external command,
operable program or batch file.

So if I run it all in a cmd window manually line by line it works, if i run the first three lines in my autoit script then run 'ss add c:hello.c' it gives me the error again.

Any ideas?

Share this post


Link to post
Share on other sites

slight update, ive added the path into the environment variables so no need for that to be in the script now, so its now just  

$sCmd = "set ssdir=\\button\home\VSS database && SET PROJECT= $/Smartbooker && ss Add C:\hello.c"
Run(@ComSpec & " /c " & $sCmd, "", @SW_SHOW)

so when I run the above I now get 'No VSS database (srcsafe.ini) found.  Use the SSDIR environment variable or run netsetup.' evern though I have set it, if I then type in 'set' it even shows me that in the current cmd window it is set 'ssdir=buttonhomeVSS database'

Any thoughts?

Share this post


Link to post
Share on other sites

water, what does && mean, is that a new line? as in does it put in 'set ssdir=buttonhomeVSS database' then essentially press enter, then the next line then enter?

Share this post


Link to post
Share on other sites

&& is the DOS command concatenator.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Does it help if you set the working directory of the Run function to "C:Program FilesMicrosoft Visual StudioVSSwin32"?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

nope same issue

No VSS database (srcsafe.ini) found.  Use the SSDIR environment variable or run netsetup.

C:\Program Files\Microsoft Visual Studio\VSS\win32>

so how would you write to press enter after a line of text being entered in the cmd window?

Share this post


Link to post
Share on other sites

Managed to get it working

$sCmd = "(set ssdir=\\button\home\VSS database) && (SET PROJECT= $/Smartbooker) && (ss Add C:\hello.c)"
Run(@ComSpec & " /k " & $sCmd, "", @SW_SHOW)

Share this post


Link to post
Share on other sites

Strange that parenthesis are needed. But glad you could solve the problem :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

yeh, the only problem now is passing a variable into it, just been searching and found a few forum posts but didnt really understand them

I know the below wont work but hopefully it will give you an idea of what im trying to do, and you might be able to point me in the right direction

local $file = "hello.c"
$sCmd = "(set ssdir=\\button\home\VSS database) && (SET PROJECT= $/Smartbooker) && (ss Add C:\"$file")"
Run(@ComSpec & " /k " & $sCmd, "", @SW_SHOW)

Share this post


Link to post
Share on other sites

Use

$sCmd = "(set ssdir=\\button\home\VSS database) && (SET PROJECT= $/Smartbooker) && (ss Add C:\" & $file & ")"

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

omg im so stupid, i tried it with the & between c:" and $file but forgot to put another one after the $file, silly me!

Cheers water works perfectly!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0