Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Forgive me if I'm not using the correct terminology here but I'll try to explain the issue I'm having as best I can!

We use a program that allows you to view video footage from several cameras, and it works in such a way that when it is opened it then automatically loads several video files within its interface. These video files are stored in a subfolder, e.g. "videos\video1.asf", etc. I didn't create the program so I can't say what method it uses to open the files.

The files are stored on a network server and are being accessed via a share/UNC path.

  • When the file is run from windows explorer (by navigating to the network share and double-clicking the exe), it works perfectly.

  • When the file is run via the (elevated) command prompt (e.g. by typing the \server\path\to\file.exe) it opens, but the corresponding video files do not load.

I am trying to create a script that launches the program via the command prompt, so the first step is finding out why the two actions above have different consequences. Any advice on how running executables from the command prompt could produce a different result would be greatly appreciated.

share|improve this question
    
Most likely an issue with the working directory. In the command prompt I would try mapping a drive to the share then changing your working directory to there before running the exe. –  EBGreen Oct 21 '13 at 15:33
    
I believe (although I can't say with 100% certainty) that when you go to the network share, you are using the 'current' logged in user credentials to connect. When you run via elevated Command Prompt, you are running as Administrator aka a different user, which may not have access to the video files - at least not that it is aware of it yet. Try running the program via windows explorer, but right click on the file.exe and Run as Administrator and see if you get the same issue. –  Darius Oct 21 '13 at 15:35
    
@EBGreen - I've tried your suggestion out of interest but it doesn't seem to work. It's also not a viable solution as we may end up overwriting a mapped drive that is in use. –  valoukh Oct 21 '13 at 15:38
    
@Darius - that makes total sense, but I've tried doing what you suggested and it still works as Administrator! –  valoukh Oct 21 '13 at 15:40
    
@valoukh - Have you tried creating a .bat file in the same location as the .exe that launches an elevated cmd.exe with the arguments to start the process in question? –  Ramhound Oct 21 '13 at 15:41
show 1 more comment

1 Answer

up vote 0 down vote accepted

Try creating a batch file which changes to the correct directory and then runs your application, eg

pushd \\server\path\to
file.exe
popd

If this does not work, then try running this batch file from an non-elevated command prompt to determine if the problem is related to the user account or the method of starting it.

If this works in non-elevated mode, but not when elevated, then download Process monitor from Sysinternals to monitor file accesses and run the program normally to see if it is attempting to load any configuration files from your local profile.

share|improve this answer
    
You are brilliant! I created the batch file as suggested and it worked perfectly, so I then transferred this logic to my script (which uses jscript/wscript.shell) and got it working using var shell = new ActiveXObject("WScript.Shell"); shell.currentdirectory = \\server\directory\etc; Thanks! –  valoukh Oct 22 '13 at 7:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.