We have this Citrix published application that we needed to run a bat file, that in turn runs a vbs script, that updates the user profile.
So like the bat file would not go away. So then I wrote a vb.net app that calls the bat file, waits a couple of seconds, closes the bat file and closes itself. It did not work. Why, something silly with the components of the .net framework over a published application. We received error messages....
System.Security.Permissions.EnvironmentalPermission, mscorlib, and bunch of other silly messages like this.
So, I took the law into my own hands, and resorted back to one of the best programming languages in the world. C++.
Below is the source code for an app that can help you launch a hidden bat file.
Here is the txt configuration file (BatFileConfig.txt). The 3 is the number of seconds it will wait before it closes the bat file and then itself.
#define n '\n'
using namespace std;
cout << "There was a problem trying to open the BatFileConfig.txt" << n;
myifstream >> pathtofileSTR >> timerpauseSTR;
ShExecInfo.lpFile = pathtofileSTR.c_str();
ShExecInfo.nShow = SW_HIDE;
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = NULL;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpParameters = NULL;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.hInstApp = NULL;