DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

wshshell issues on windows 10

Hi 

I am developing a script on Diadem 2017 on windows 10 (google cloud vm)

 

This works perfectly if I run it on my laptop (windows 7) within diadem

dim commandfile:commandfile="C:\Diadem\" & filenamesrc & ".bat"
dim command:command="gsutil -m -q   cp """ & gspath & """ C:\FilesToProcess"
WshShell.run(commandfile)

 

However on Windows 10 

I get a message saying it cant find the file (gsutil) (for both exec and run)
If I run it direct from command shell it works

 

Any ideas

0 Kudos
Message 1 of 9
(8,855 Views)

Hey redtux,

 

Just to be sure: Your script has a command like "set WshShell = CreateObject ("WScript.Shell")" in it, right? (Would give a different error message if not, but...)

 

Try this first:

Option Explicit
dim shell
set shell = CreateObject("Wscript.Shell")
shell.run("notepad")

Does it successfully open notepad?

 

If so, I believe there might be something wrong in your system's environment variable PATH definition. I assume ghostscript(?) might be included in your user's PATH but not in the system one it perhaps uses when executing from DIAdem? Check "Control Panel»System»Advanced System Settings»Environment Variables" and then search for path both in "User variables" and "System variables". It should have your installation path of "gsutil" in there, e.g. "c:\program files\gs\".


Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
CLADMSD
0 Kudos
Message 2 of 9
(8,828 Views)

gspath is the path to a file on gcloud eg: gs://googlebucket/Vehicle 301169/301169/406197/DTC_Read 2018-07-27 13-11-08-242874 Partition 0.dat 

(and not ghostscript)

The issue is that diadem isn't seeing the path for some reason

path is C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin;C:\Program Files\Google\Compute Engine\sysprep\;C:\Program Files\Google\Compute Engine\metadata_scripts\;C:\Program Files\Puppet Labs\Puppet\bin;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin

If I run it as "cmd /c gsutil -m -q   cp """ & gspath & """ C:\FilesToProcess"

It works, though that has the issue of return values and process control

 

Mike

 

0 Kudos
Message 3 of 9
(8,824 Views)

Further investigation

It doesnt seem to accept any non-gui or non-interactive command

eg : "dir C:\FilesToProcess"

has the same error

 

0 Kudos
Message 4 of 9
(8,823 Views)

@redtux wrote:

eg : "dir C:\FilesToProcess"

has the same error


If you tried to execute this with "WScript.shell.run("dir c:\")", then I can explain the behavior you saw:

"dir" originally was a DOS-command, that was directly built into DOS' command interpreter command.com (similar to Unix' bash). It never was a specific program executed, but a command directly interpreted in command.com. See the second paragraph in List of DOS commands for more information. Nowadays, it is implemented in cmd.exe.

 

When you run "WScript.shell.run("dir c:\")", Windows' service wscript.exe searches for an executable file like dir.exe, dir.cmd, or dir.bat, and won't find one. Run "WScript.shell.run("cmd /c dir c:\")" instead, and it will work.


Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
CLADMSD
0 Kudos
Message 5 of 9
(8,812 Views)

@redtux wrote:

gspath is the path to a file on gcloud eg: gs://googlebucket/Vehicle 301169/301169/406197/DTC_Read 2018-07-27 13-11-08-242874 Partition 0.dat 

(and not ghostscript)

The issue is that diadem isn't seeing the path for some reason

path 


Oh, I didn't know that. Ok, do you know which path exactly isn't seen? Is it that WScript cannot find the path gsutil.exe is in or is it that gsutil cannot see the gs:// path?

 

I assume that gsutil.exe is in C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin, therefore the former should work.

To test it, you can probably run "gsutil test -u" or "gsutil version".

 

If it is that gsutil cannot resolve gs:// paths when running in the WScript context, then this might be because of the approach they used to implemented gs:// protocol support in Windows. However, I cannot believe it shall not work in this context, as we are talking about modern software.

 


@redtux wrote:

 

If I run it as "cmd /c gsutil -m -q   cp """ & gspath & """ C:\FilesToProcess"

It works, though that has the issue of return values and process control

 


Have you tried using WScript.Shell.Exec instead of .Run? Normaly this gives you access to the output stream.

This works for me in DIAdem:

Option Explicit
dim shell
set shell = CreateObject("Wscript.Shell")
dim r
set r = shell.exec("cmd /c dir c:\")
do while r.status = 0 '0: still running
  call pause(0.1)
loop
if r.status=1 then '1: finished
   msgbox r.stdout.readall
end if

 

 

 


Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
CLADMSD
0 Kudos
Message 6 of 9
(8,808 Views)
Option Explicit
dim wsh : set wsh = CreateObject( "WScript.Shell" )
LogFileWrite wsh.ExpandEnvironmentStrings( "%PATH%" )

is the path the same in DIAdem?

Message 7 of 9
(8,790 Views)

yep, exactly the same

0 Kudos
Message 8 of 9
(8,776 Views)

I checked with on my windows 10 machine but it seems to work fine with an additional path.

 

If you call

where gsutil

in cmd does it return the path to the exe?

 

Does it work if you use a fullpath?

 

0 Kudos
Message 9 of 9
(8,750 Views)