Trying to edit the DyanmoSettings.xml file without installing any specific packages on the Windows systems (sed, awk, etc)
to do:
need to modify this file;
%appdata%\dynamo\Dynamo Revit\2.3\DynamoSettings.xml
and within that file above, find this line;
>
> <CustomPackageFolders>
> <string>C:\Users\user1.mydomain\AppData\Roaming\Dynamo\Dynamo Revit\2.3</string>
> </CustomPackageFolders>
>
and add 'C:\Users%USERNAME%\OneDrive\DT-s\Revit Scripts\Dynamo\Custom Packages '
so it looks like this;
>
> <CustomPackageFolders>
> <string>C:\Users\user1.mydomain\AppData\Roaming\Dynamo\Dynamo Revit\2.3</string>
> <string>C:\Users\%USERNAME%\OneDrive\DT-s\Revit Scripts\Dynamo\Custom Packages </string>
> </CustomPackageFolders>
>
>
TIA!
tried using standard >> method in CMD but this didn't work.
Powershell uses c#. So any c# code can run inside powershell without any installation. Code below uses the c# library Xml Linq. Try following
using assembly System
using assembly System.Xml.Linq
$Filename = "c:\temp\test.xml"
$xDoc = [System.Xml.Linq.XDocument]::Load($Filename)
$customFolder = $xDoc.Descendants("CustomPackageFolders")
$newElement = [System.Xml.Linq.XElement]::new("string","C:\Users\%USERNAME%\OneDrive\DT-s\Revit Scripts\Dynamo\Custom Packages")
$customFolder.Add($newElement)
Write-Host "customFolder = " $customFolder
$xDoc.Save("c:\temp\test1.xml")
If that xml file looks anything like this
<DynamOconfig>
<CustomPackageFolders>
<string>C:\Users\user1.mydomain\AppData\Roaming\Dynamo\Dynamo Revit\2.3</string>
</CustomPackageFolders>
</DynamOconfig>
then
# load the settings file
$xml = [System.Xml.XmlDocument]::new()
$xml.Load("$env:APPDATA\dynamo\Dynamo Revit\2.3\DynamoSettings.xml")
# create a new <string> node
$newNode = $xml.CreateElement('string')
$newNode.InnerText = 'C:\Users\%USERNAME%\OneDrive\DT-s\Revit Scripts\Dynamo\Custom Packages'
# find the <CustomPackageFolders> node and append the new node to it
[void]$xml.SelectSingleNode('//CustomPackageFolders').AppendChild($newNode)
# save to (for safety NEW) file
$xml.Save("$env:APPDATA\dynamo\Dynamo Revit\2.3\NEW_DynamoSettings.xml")
Result:
<DynamOconfig>
<CustomPackageFolders>
<string>C:\Users\user1.mydomain\AppData\Roaming\Dynamo\Dynamo Revit\2.3</string>
<string>C:\Users\%USERNAME%\OneDrive\DT-s\Revit Scripts\Dynamo\Custom Packages</string>
</CustomPackageFolders>
</DynamOconfig>
P.S. If your intention is to have %USERNAME% interpolated in the string so it expands to your username, then create the new node's innertext like ths:
$newNode.InnerText = "C:\Users\$env:USERNAME\OneDrive\DT-s\Revit Scripts\Dynamo\Custom Packages"
(mind you need double-quotes now)
I want to do this things :
select a session
make a dump of this session (the issue is here)
Plus, I want to do that without modification of Fiddler Rules. I have done this with a modification of Fiddler Rules but the program will be used on several machines and it can be difficult to change Fiddler Rules in every machines.
I don't know if it is possible.
The code to do that with the modification of the fiddler Rules is :
PowerShell :
$filePath = "...\nameFile.txt" # file which contain the names of fiddler ZIP files
$file = Get-Content $filePath # content of nameFile
foreach ($line in $file) {
start $line # open the file
Write-Host "File : $line open"
Start-Sleep -s 1
}
& "...\Fiddler\ExecAction.exe" "failuresselection" # select all failures and make another file (see Fiddler Rules)
Fiddler Rules :
static function OnExecAction(sParams: String[]): Boolean {
[...]
// Select all failures and put them in a new ZIP file
case "failuresselection":
var path = "...\\Newlogs";
UI.actSelectSessionsWithResponseCode(449);
if (UI.GetFirstSelectedSession() != null){
UI.actSaveSessionsToZip(path+"\\Logs" + 449 + ".saz");
}
// Confirmation
FiddlerObject.StatusText = "Dumped all failures sessions to " + path;
UI.actExit();
return true;
[...]
}
I try this but it doesn't worked :
& "...\Fiddler\ExecAction.exe" "FiddlerApplication.UI.actSelectAll();"
It's to select all line but I think that ExecAction.exe replace QuickExec.
In summary, I am searching a way to do the same thing without modification of Fiddler Rules.
I have an output variable siteToDeploy and siteToStop. I am using postman to run a test script against the IIS Administration API. In the test portion of one of the requests I am trying to set the azure devops output variable. Its sort of working, but the variable value is getting cut off for some reason.
Here is the test script in postman:
console.log(pm.globals.get("siteName"))
var response = pm.response.json();
var startedSite = _.find(response.websites, function(o) { return o.name.indexOf(pm.globals.get("siteName")) > -1 && pm.globals.get("siteName") && o.status == 'started'});
var stoppedSite = _.find(response.websites, function(o) { return o.name.indexOf(pm.globals.get("siteName")) > -1 && o.status == 'stopped'});
if(stoppedSite && startedSite){
console.log('sites found');
console.log(stoppedSite.id)
console.log('##vso[task.setvariable variable=siteToDeploy;]' + stoppedSite.id);
console.log('##vso[task.setvariable variable=siteToStop;]' + startedSite.id);
}
Here is the output form Newman:
Here is the output from a command line task echoing the $(siteToDeploy) variable. It's getting set, but not the entire value.
I've tried escaping it, but that had no effect. I also created a static command line echo where the variable is set and that worked fine. So I am not sure if it is a Newman issue or Azure having trouble picking up the varaible.
The issue turned our to be how Azure is trying to parse the Newman console log output. I had to add an extra Powershell task to replace the ' coming back from the Newman output.
This is what is looks like:
##This task is only here because of how Newman is writing out the console.log
Param(
[string]$_siteToDeploy = (("$(siteToDeploy)") -replace "'",""),
[string]$_siteToStop = (("$(siteToStop)") -replace "'","")
)
Write-Host ("##vso[task.setvariable variable=siteToDeploy;]{0}" -f ($_siteToDeploy))
Write-Host ("##vso[task.setvariable variable=siteToStop;]{0}" -f ($_siteToStop))
I need to know how to make popup messages in batch scripts without using VBScript or KiXtart or any other external scripting/programming language.
I have zero clue about this... had no starting point even.
I am aware of NET SEND but the Messenger service is disabled in my current environment.
msg * "Enter Your Message"
Does this help ?
With regard to LittleBobbyTable's answer - NET SEND does not work on Vista or Windows 7. It has been replaced by MSG.EXE
There is a crude solution that works on all versions of Windows - A crude popup message can be sent by STARTing a new cmd.exe window that closes once a key is pressed.
start "" cmd /c "echo Hello world!&echo(&pause"
If you want your script to pause until the message box is dismissed, then you can add the /WAIT option.
start "" /wait cmd /c "echo Hello world!&echo(&pause"
You can take advantage of CSCRIPT.EXE or WSCRIPT.EXE (which have been present in every version of Windows since, I believe, Windows 95) like this:
echo msgbox "Hey! Here is a message!" > %tmp%\tmp.vbs
cscript /nologo %tmp%\tmp.vbs
del %tmp%\tmp.vbs
or
echo msgbox "Hey! Here is a message!" > %tmp%\tmp.vbs
wscript %tmp%\tmp.vbs
del %tmp%\tmp.vbs
You could also choose the more customizeable PopUp command. This example gives you a 10 second window to click OK, before timing out:
echo set WshShell = WScript.CreateObject("WScript.Shell") > %tmp%\tmp.vbs
echo WScript.Quit (WshShell.Popup( "You have 10 seconds to Click 'OK'." ,10 ,"Click OK", 0)) >> %tmp%\tmp.vbs
cscript /nologo %tmp%\tmp.vbs
if %errorlevel%==1 (
echo You Clicked OK
) else (
echo The Message timed out.
)
del %tmp%\tmp.vbs
In their above context, both cscript and wscript will act the same. When called from a batch file, bot cscript and wscript will pause the batch file until they finish their script, then allow the file to continue.
When called manually from the command prompt, cscript will not return control to the command prompt until it is finished, while wscript will create a seprate thread for the execution of it's script, returning control to the command prompt even before it's script has finished.
Other methods discussed in this thread do not cause the execution of batch files to pause while waiting for the message to be clicked on. Your selection will be dictated by your needs.
Note: Using this method, multiple button and icon configurations are available to cover various yes/no/cancel/abort/retry queries to the user: https://technet.microsoft.com/en-us/library/ee156593.aspx
Few more ways (in all of them the script waits for button pressing unlike msg.exe).
1) The geekiest and hackiest - it uses the IEXPRESS to create small exe that will create a pop-up with a single button (it can create two more types of pop-up messages).Works on EVERY windows from XP and above:
;#echo off
;setlocal
;set ppopup_executable=popupe.exe
;set "message2=%~1"
;
;del /q /f %tmp%\yes >nul 2>&1
;
;copy /y "%~f0" "%temp%\popup.sed" >nul 2>&1
;(echo(FinishMessage=%message2%)>>"%temp%\popup.sed";
;(echo(TargetName=%cd%\%ppopup_executable%)>>"%temp%\popup.sed";
;(echo(FriendlyName=%message1_title%)>>"%temp%\popup.sed"
;
;iexpress /n /q /m %temp%\popup.sed
;%ppopup_executable%
;rem del /q /f %ppopup_executable% >nul 2>&1
;pause
;endlocal
;exit /b 0
[Version]
Class=IEXPRESS
SEDVersion=3
[Options]
PackagePurpose=InstallApp
ShowInstallProgramWindow=1
HideExtractAnimation=1
UseLongFileName=0
InsideCompressed=0
CAB_FixedSize=0
CAB_ResvCodeSigning=0
RebootMode=N
InstallPrompt=%InstallPrompt%
DisplayLicense=%DisplayLicense%
FinishMessage=%FinishMessage%
TargetName=%TargetName%
FriendlyName=%FriendlyName%
AppLaunched=%AppLaunched%
PostInstallCmd=%PostInstallCmd%
AdminQuietInstCmd=%AdminQuietInstCmd%
UserQuietInstCmd=%UserQuietInstCmd%
SourceFiles=SourceFiles
[SourceFiles]
SourceFiles0=C:\Windows\System32\
[SourceFiles0]
%FILE0%=
[Strings]
AppLaunched=subst.exe
PostInstallCmd=<None>
AdminQuietInstCmd=
UserQuietInstCmd=
FILE0="subst.exe"
DisplayLicense=
InstallPrompt=
;
Example Usage (if you save the script as expPopup.bat):
call expPopup.bat "my Message"
2) Using MSHTA. Also works on every windows machine from XP and above (despite yhe OP do not wants "external" languages the jsvascript here is minimized).Should be saved as .bat:
#if (true == false) #end /*!
#echo off
mshta "about:<script src='file://%~f0'></script><script>close()</script>" %*
goto :EOF */
alert("Hello, world!");
or in one line:
mshta "about:<script>alert('Hello, world!');close()</script>"
or
mshta "javascript:alert('message');close()"
or
mshta.exe vbscript:Execute("msgbox ""message"",0,""title"":close")
3) Here's parametrized .bat/jscript hybrid (should be saved as bat) .It again uses jscript despite the OP request but as it is a bat it can be called as a bat file without worries.It uses POPUP which allows a little bit more control than the more populae MSGBOX.It uses WSH ,but not MSHTA like in the example above.
#if (#x)==(#y) #end /***** jscript comment ******
#echo off
cscript //E:JScript //nologo "%~f0" "%~nx0" %*
exit /b 0
#if (#x)==(#y) #end ****** end comment *********/
var wshShell = WScript.CreateObject("WScript.Shell");
var args=WScript.Arguments;
var title=args.Item(0);
var timeout=-1;
var pressed_message="button pressed";
var timeout_message="timedout";
var message="";
function printHelp() {
WScript.Echo(title + "[-title Title] [-timeout m] [-tom \"Time-out message\"] [-pbm \"Pressed button message\"] [-message \"pop-up message\"]");
}
if (WScript.Arguments.Length==1){
runPopup();
WScript.Quit(0);
}
if (args.Item(1).toLowerCase() == "-help" || args.Item(1).toLowerCase() == "-h" ) {
printHelp();
WScript.Quit(0);
}
if (WScript.Arguments.Length % 2 == 0 ) {
WScript.Echo("Illegal arguments ");
printHelp();
WScript.Quit(1);
}
for (var arg = 1 ; arg<args.Length;arg=arg+2) {
if (args.Item(arg).toLowerCase() == "-title") {
title = args.Item(arg+1);
}
if (args.Item(arg).toLowerCase() == "-timeout") {
timeout = parseInt(args.Item(arg+1));
if (isNaN(timeout)) {
timeout=-1;
}
}
if (args.Item(arg).toLowerCase() == "-tom") {
timeout_message = args.Item(arg+1);
}
if (args.Item(arg).toLowerCase() == "-pbm") {
pressed_message = args.Item(arg+1);
}
if (args.Item(arg).toLowerCase() == "-message") {
message = args.Item(arg+1);
}
}
function runPopup(){
var btn = wshShell.Popup(message, timeout, title, 0x0 + 0x10);
switch(btn) {
// button pressed.
case 1:
WScript.Echo(pressed_message);
break;
// Timed out.
case -1:
WScript.Echo(timeout_message);
break;
}
}
runPopup();
example usage (it will wait 10 seconds to press the yes button):
jsPopup.bat -title CoolTitile -t 10 -tom "time out" -pbm "press the button please" -message "love and peace"
4) and one jscript.net/.bat hybrid (should be saved as .bat) .This time it uses .NET and compiles a small .exe file that could be deleted:
#if (#X)==(#Y) #end /****** silent jscript comment ******
#echo off
::::::::::::::::::::::::::::::::::::
::: compile the script ::::
::::::::::::::::::::::::::::::::::::
setlocal
::if exist "%~n0.exe" goto :skip_compilation
:: searching the latest installed .net framework
for /f "tokens=* delims=" %%v in ('dir /b /s /a:d /o:-n "%SystemRoot%\Microsoft.NET\Framework\v*"') do (
if exist "%%v\jsc.exe" (
rem :: the javascript.net compiler
set "jsc=%%~dpsnfxv\jsc.exe"
goto :break_loop
)
)
echo jsc.exe not found && exit /b 0
:break_loop
call %jsc% /nologo /out:"%~n0.exe" "%~f0"
::::::::::::::::::::::::::::::::::::
::: end of compilation ::::
::::::::::::::::::::::::::::::::::::
:skip_compilation
::
::::::::::
"%~n0.exe" %*
::::::::
::
endlocal
exit /b 0
****** end of jscript comment ******/
import System;
import System.WIndows;
import System.Windows.Forms
var arguments:String[] = Environment.GetCommandLineArgs();
MessageBox.Show(arguments[1],arguments[0]);
Example usage:
netPopUp.bat "Roger That"
5) and at the end one single call to powershell that creates a pop-up (can be called from command line or from batch if powershell is installed):
powershell [Reflection.Assembly]::LoadWithPartialName("""System.Windows.Forms""");[Windows.Forms.MessageBox]::show("""Hello World""", """My PopUp Message Box""")
6) Though msg solution is already post as answer here's a better way to be used:
msg * /self /w "hello world"
/self is a not documented switch that will force msg to send the message only to the current user.
msg * Hello world
works for me..
So, i present cmdmsg.bat.
The code is:
#echo off
echo WScript.Quit MsgBox(%1, vbYesNo) > #.vbs
cscript //nologo #.vbs
echo. >%ERRORLEVEL%.cm
del #.vbs
exit /b
And a example file:
#echo off
cls
call cmdmsg "hi select yes or no"
if exist "6.cm" call :yes
if exist "7.cm" call :no
:yes
cls
if exist "6.cm" del 6.cm
if exist "7.cm" del 7.cm
echo.
echo you selected yes
echo.
pause >nul
exit /b
:no
cls
if exist "6.cm" del 6.cm
if exist "7.cm" del 7.cm
echo.
echo aw man, you selected no
echo.
pause >nul
exit /b
I put together a script based on the good answers here & in other posts
You can set title timeout & even sleep to schedule it for latter & \n for new line
also you get back the key press into a variable (%pop.key%).
Here is my code
Your best bet is to use NET SEND as documented on Rob van der Woude's site.
Otherwise, you'll need to use an external scripting program. Batch files are really intended to send messages via ECHO.
This is very simple beacuse i have created a couple lines of code that will do this for you
So set a variable as msg and then use this code. it popup in a VBS message box.
CODE:
#echo off
echo %msg% >vbs.txt
copy vbs.txt vbs.vbs
del vbs.txt
start vbs.vbs
timeout /t 1
del vbs.vbs
cls
This is just something i came up with it should work for most of your message needs and it also works with Spaces unlike some batch scripts
It's easy to make a message, here's how:
First open notpad and type:
msg "Message",0,"Title"
and save it as Message.vbs.
Now in your batch file type:
Message.vbs %*
msg * message goes here
That method is very simple and easy and should work in any batch file i believe. The only "downside" to this method is that it can only show 1 message at once, if there is more than one message it will show each one after the other depending on the order you put them inside the code. Also make sure there is a different looping or continuous operator in your batch file or it will close automatically and only this message will appear. If you need a "quiet" background looping opperator, heres one:
pause >nul
That should keep it running but then it will close after a button is pressed.
Also to keep all the commands "quiet" when running, so they just run and dont display that they were typed into the file, just put the following line at the beginning of the batch file:
#echo off
I hope all these tips helped!
I'm part of a team newly using mercurial and we've identified that when merges occur there are many more errors in files that are manually merged. Is it possible from the mercurial logs (i.e. after someone has done the merge and pushed the merge changeset to the central repository) to detect which files were manually merged?
Note, that I have no idea if this is foolproof. Also, it requires a copy of my as of yet unfinished Mercurial library for .NET, probably only runs on Windows, and is kinda rough around the edges.
Note: I'm assuming that by "were manually merged", you mean "files Mercurial didn't automatically merge for us"
Such a file could still be merged somewhat or completely automatic by an external tool, but if the above assumption is good enough, read on.
However, what I did was to effectively run through all the merges in a test repository, re-doing the merges and asking Mercurial to use only its internal merge tool, which leaves files unresolved if they cannot be automatically merged by Mercurial, and then report all unresolved files, clean up the merge, and move on to the next merge changeset.
The library you need (only in source code form at the moment, I told you it was unfinished):
Mercurial.Net (my open source project, hosted on CodePlex)
I've attached a zip file at the bottom with everything, test repository, script, and binary copy of library.
The script (I used LINQPad to write and test this, output from a test-repository follows):
void Main()
{
var repo = new Repository(#"c:\temp\repo");
var mergeChangesets = repo.Log(new LogCommand()
.WithAdditionalArgument("-r")
.WithAdditionalArgument("merge()")).Reverse().ToArray();
foreach (var merge in mergeChangesets)
{
Debug.WriteLine("analyzing merge #" + merge.RevisionNumber +
" between revisions #" + merge.LeftParentRevision +
" and #" + merge.RightParentRevision);
// update to left parent
repo.Update(merge.LeftParentHash);
try
{
// perform merge with right parent
var mergeCmd = new MergeCommand();
mergeCmd.WithRevision = merge.RightParentHash;
repo.Execute(mergeCmd);
// get list of unresolved files
var resolveCmd = new ResolveCommand();
repo.Execute(resolveCmd);
var unresolvedFiles = new List<string>();
using (var reader = new StringReader(resolveCmd.RawStandardOutput))
{
string line;
while ((line = reader.ReadLine()) != null)
if (line.StartsWith("U "))
unresolvedFiles.Add(line.Substring(2));
}
// report
if (unresolvedFiles.Count > 0)
{
Debug.WriteLine("merge changeset #" + merge.RevisionNumber +
" between revisions #" + merge.LeftParentRevision +
" and #" + merge.RightParentRevision + " had " +
unresolvedFiles.Count + " unresolved file(s)");
foreach (string filename in unresolvedFiles)
{
Debug.WriteLine(" " + filename);
}
}
}
finally
{
// get repository back to proper state
repo.Update(merge.LeftParentHash, new UpdateCommand().WithClean());
}
}
}
public class MergeCommand : MercurialCommandBase<MergeCommand>
{
public MergeCommand()
: base("merge")
{
}
[NullableArgumentAttribute(NonNullOption = "--rev")]
public RevSpec WithRevision
{
get;
set;
}
public override IEnumerable<string> Arguments
{
get
{
foreach (var arg in base.Arguments)
yield return arg;
yield return "--config";
yield return "ui.merge=internal:merge";
}
}
protected override void ThrowOnUnsuccessfulExecution(int exitCode,
string standardOutput, string standardErrorOutput)
{
if (exitCode != 0 && exitCode != 1)
base.ThrowOnUnsuccessfulExecution(exitCode, standardOutput,
standardErrorOutput);
}
}
public class ResolveCommand : MercurialCommandBase<MergeCommand>
{
public ResolveCommand()
: base("resolve")
{
}
public override IEnumerable<string> Arguments
{
get
{
foreach (var arg in base.Arguments)
yield return arg;
yield return "--list";
}
}
}
The sample output:
analyzing merge #7 between revisions #5 and #6
analyzing merge #10 between revisions #9 and #8
merge changeset #10 between revisions #9 and #8 had 1 unresolved file(s)
test1.txt
Zip-file with everything (LINQPad script, Mercurial.Net assembly, go compile it if you don't trust me, and the test repository I executed it against above):
here: zip-file
BIG CAVEAT: Run this only in a clone of your repository! I won't be held responsible if this corrupts your repository, however unlikely I think that would be.
Tis is the shell script variant of Lasses answer:
#!/bin/bash
test "$1" = "--destroy-my-working-copy" || exit
hg log -r 'merge()' --template '{parents} {rev}\n' | sed -e 's/[0-9]*://g' | while read p1 p2 commit
do
echo "-------------------------"
echo examine $commit
LC_ALL=C hg up -C -r $p1 >/dev/null
LC_ALL=C hg merge -r 26 --config ui.merge=internal:merge 2>&1 | grep failed
done
hg up -C -r tip > /dev/null
Example output:
> mergetest.sh --destroy-my-working-copy
-------------------------
examine 7
-------------------------
examine 11
-------------------------
examine 23
-------------------------
examine 31
-------------------------
examine 37
merging test.py failed!