WshShell
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
WshShell
I am trying to run a command ""DIR > D:\\test1234765437189.txt"" through WshShell, but am unable to run the same. This command is used to copy all the output of command prompt.
Also alternative to this is to use "<<D:\\test1234765437189.txt" in continuation to any command. This also does not work.
Can you please suggest a solution regarding the same
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What does your entire script look like, can you paste your code please?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
function testing(){
var bimdumperlocation="C:\\Users\\Sanket.Vaidya\\AppData\\Local\\imodelbridges\\ProStructures\\bimdumper.exe";
var input="--input=C:\\Users\\Sanket.Vaidya\\Downloads\\test.bim";
var dumpschema="--dump-schemas --dump-elements";
var signaturefile=">> C:\\testabcd.txt";
var command=bimdumperlocation+" "+input+" "+dumpschema+" "+signaturefile;
WshShell.Run(command);
}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The command in signature variable is not running.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does it work, if you run the command in the Command Prompt?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes, it works, the complete command that forms up is
C:\Users\Sanket.Vaidya\AppData\Local\imodelbridges\ProStructures\bimdumper.exe --input=C:\Users\Sanket.Vaidya\Downloads\test.bim --dump-schemas --dump-elements >> D:\\test1234474437189.txt
if I enter this command in command prompt then the file test1234474437189.txt is created in 😧 location
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Could you try,
getActiveXObject("WScript.Shell").Run("Enter you command here");
or
var command = "cmd /c " + "Enter your command here"
var oExe = Sys.OleObject("WScript.Shell");
oExe.Run(command)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You're trying to write output to the root of C. Many systems, etc., prevent writing to the root of C for security reasons. What if you change "signaturefile" to be writing to a subfolder instead?
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Its not issue of C location. I used the below script its working now.
var bimdumperlocation="C:\\Users\\Sanket.Vaidya\\AppData\\Local\\imodelbridges\\ProStructures\\bimdumper.exe";
var input="--input=C:\\Users\\Sanket.Vaidya\\Downloads\\test.bim";
var dumpschema="--dump-schemas --dump-elements";
var signaturefile=Project.Variables.Var1 + " C:\\testabcd23.txt";
var command=bimdumperlocation+" "+input+" "+dumpschema+" "+signaturefile;
var cmd1=Sys.OleObject("WScript.Shell").Run("C:\\Windows\\system32\\cmd.exe /c" +command);
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The parameter /C Carries out the command specified by string and then terminates.
