robopp 0 Posted May 8, 2020 Is there a way to get the desktop path programatically? The cmd desktop path shortcut - %userprofile%/desktop - doesn't work. Share this post Link to post Share on other sites
AzeoTech 0 Posted May 8, 2020 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. Share this post Link to post Share on other sites
robopp 0 Posted May 8, 2020 Makes sense. Thank you! Share this post Link to post Share on other sites
ajsenko 0 Posted June 3 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 I Share this post Link to post Share on other sites
ajsenko 0 Posted June 6 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. Share this post Link to post Share on other sites
AzeoTech 0 Posted June 6 Yes, that would be the way. You can't just pass a batch file to CMD.exe, but instead have to use a flag to tell it to run the particular file. You can use /C or /K depending on whether you want the window to stay open. Share this post Link to post Share on other sites