Getting Desktop Path


Recommended Posts

Not built in.  I would probably use a trick, probably with a batch file.  The batch file would just have something like:

echo %userprofile%/desktop > c:\data\desktopPath.txt

You'd run it from DAQFactory using shellExecute():

system.shellExecute("cmd.exe","c:\data\myBatchFile.bat")

Then you can simply use the file. functions to read the desktopPath.txt file and get the results.

This is off the cuff, but should work, possibly with minor tweaks.  Test each part.

Link to comment
Share on other sites

  • 2 years later...
On 5/8/2020 at 4:04 PM, AzeoTech said:

Not built in.  I would probably use a trick, probably with a batch file.  The batch file would just have something like:

echo %userprofile%/desktop > c:\data\desktopPath.txt

You'd run it from DAQFactory using shellExecute():

system.shellExecute("cmd.exe","c:\data\myBatchFile.bat")

Then you can simply use the file. functions to read the desktopPath.txt file and get the results.

This is off the cuff, but should work, possibly with minor tweaks.  Test each part.

Hi, I'm also trying to run a batch file, and "system.shellExecute("cmd.exe","c:\data\myBatchFile.bat")" doesn't do anything. 

function LoadAutosamplerFile(string que_file)
   //try
      private string script_dir = "C:\Peak489Win10\LoadCtrlFile.bat"
      private handle = file.Open(script_dir, 0, 1, 0, 1)
      File.Write(handle, "cd C:\Peak489Win10")
      File.Write(handle, "Peak489Win10 -a" + que_file)
      File.Close(handle)
      system.ShellExecute("cmd.exe","C:\Peak489Win10\LoadCtrlFile.bat")
      ?"Batch file (allegedly) executed"
      return 1

Link to comment
Share on other sites

Figured it out, the command to launch a batch file with shellExecute is 

system.ShellExecute("cmd.exe", "open", "/C C:\data\myBatchFile.bat") 

At least thats the way I got it to work, hope this helps if anyone is looking for how to do that. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.