Jump to content

cmd with varible


Go to solution Solved by cookiemonster,

Recommended Posts

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.

Link to comment
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

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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)
Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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?

Link to comment
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?

Link to comment
Share on other sites

&& is the DOS command concatenator.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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)
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...