robopp Posted May 8, 2020 Share Posted May 8, 2020 Is there a way to get the desktop path programatically? The cmd desktop path shortcut - %userprofile%/desktop - doesn't work. Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted May 8, 2020 Share 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. Quote Link to comment Share on other sites More sharing options...
robopp Posted May 8, 2020 Author Share Posted May 8, 2020 Makes sense. Thank you! Quote Link to comment Share on other sites More sharing options...
ajsenko Posted June 3, 2022 Share Posted June 3, 2022 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 Quote Link to comment Share on other sites More sharing options...
ajsenko Posted June 6, 2022 Share Posted June 6, 2022 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. Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted June 6, 2022 Share Posted June 6, 2022 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.