Registry command entry isn't running like it runs in command line - command-line

My question clarified is, "What's different about running a command from within the registry at command line compared to running the same command from in a command line? Then how do I make it the same to work the way I want?"
Information about my program:
This is a ClickOnce application and from what I see there isn't a great way of getting the exact path of the exe instead of the appref-ms. So there is a caveat to my question this whole thing can be avoided if there was a way to find the exact path of the exe each time the program is deployed and I am able to edit the registry to point to said written down path.
I have this entry in HKEY_CLASSES_ROOT please see evidence below:
So right clicking below should work everything is typed in right, but it doesn't work.
So I figured maybe it didn't like my %APPDATA% which honestly should not matter and I got a new error message.
Just so you know my program does work and it's doing something and pulling paths from the args passed to it.
Thank you for reading my lengthy question.

Here is how you set up what I have been trying to setup for a while now. This explanation is assuming you know exactly what you are trying to do.
Publishing A (Offline) ClickOnce Application With Command Line Args Ran From A Right Click Context Menu Item That You Can Deploy As Many Times As You Want Without Editing the Registry Each Time.
If you are doing an online one just use this CTRL+F and type in deadlydog it has two stellar links in that answer. That is much simpler then this below.
Have a project that is published deployed on a file share using ClickOnce in Visual Studio project properties.
Get this code. (If you need multiple args treat them all as one large string then split it)
'VB.NET style code
Dim activationData() As String = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData
MsgBox(activationData(0)) 'Your big long argument before being split editted or modified.
Why I asked this question and my answer to it.
Make a registry entry using ContextEdit as if you were making your very normal run of the mill context menu for your program. HOWEVER!!!! click the check box that says "expand environment variables".
So the command that you type in should look like this.
cmd.exe /C ""%InsertEnvironmentVariable%\Path\Name To\Your File.appref-ms" "%1""
It should work from that it was a ton of googling mostly because I have never done this and I give up easily on ideas. Also would like to comment on the information for command line and the registry is atrociously organized and abundant beyond belief.
Hope this helps someone trying to deploy a neat clickonce lightweight program that seems integrated like a normal program.

Related

How can I fix Visual Studio Code so that it runs and debugs simple basic scripts (.bas files)? [duplicate]

This question already has answers here:
VBS Script - Need to change msgbox to echo
(3 answers)
Closed 9 months ago.
Background
I'm a tech writer but have dabbled in coding for many years now. For work, I need to test about a hundred different ancient script samples. The samples are stored in our documentation. They are in written in Basic (technically, in Cypress Enable BASIC, but it's essentially very similar if not identical to Basic scripting). I need to test them and fix any that are broken.
I want to set up Visual Studio Code to run these because I love VSC as it has a lot of benefits over the very old and vanilla scripting editor included with our product that I've been using.
My Need
Mainly, I need to be able to copy and paste the code I want to test into VSC into a simple .bas file and then run and test the code inside VSC with code coloring, code running, and a debugger. Intellisense would also be helpful. I can get color coding, but getting it to run and debug isn't working.
What I've Tried and Other Notes
I've already spent hours trying to set something up, but can't figure it out.
I have Windows 10
From something I found online, I've mapped this folder C:\Windows\Microsoft.NET\Framework64\v3.5 to my system's Path Environment Variable. (where <user> is my user name).
I've also tried different vbscript and vba related extensions, but have since uninstalled them as nothing seemed to resolve this very basic (no pun intended) problem.
I've searched various posts online and in this site, but haven't found a solution yet.
I tried enabling Run in Terminal in Code-runner to see if that made any difference.
Something is wrong, as I consistently get errors. For example, with Code Runner extension installed, if I try to run this very simple vbscript to show a test message box...
Sub Main ()
Dim testString
testString = "Meh... Will it work?"
MsgBox testString
End Sub
...I get this result in my VSC Output window:
[Running] cscript //Nologo "d:\Temp\vbscripttest.bas"
[Done] exited with code=0 in 0.174 seconds
I find very little info searching on code=0 error that is useful.
My script is in my d:\temp folder. I don't know if that makes a difference. If I try running the .bas file from the File Explorer window directly by double-clicking on it, nothing happens. Though from the icon style, it appears to be mapped to VBScript.
I gather either Windows or vbcode or both can't find the vbscripting goodness that makes things work, though I thought pointing the path variable to C:\Windows\Microsoft.NET\Framework64\v3.5 would fix that.
After two days of pulling my eyebrows out using our product's internal script editor to test my scripts (my hair has long since gone), I am hankering for some good old fashioned debugging support in my favorite code editor!
What do you recommend I do to get things working? Thank you in advance for your help.
Your sample program is running successfully. In that file there is no code in the code path. VBScript in a top level language (unlike VBA). That means code runs outside of a sub or function.
So insert before the first line Main to call Main. Or lose the Sub ... End Sub for VBScript. In VBA/VB6 you would choose Sub Main as the startup sub in Properties.
While this is not your problem, just to be complete, if you start a script in CScript or WScript using //b command line parameter then message boxes are not displayed. See CScript /?.

How do I convert a PowerShell script with custom modules into a single executable?

I've written a simple script that has multiple custom functions stored as modules. I have done it this way because I was always been told that if your function can be reused by other things then it should be a module and not a .\ source include. I'm starting to think that mantra isn't right in my current scenario. I am trying to convert the script to an single .exe so that I can install it as a windows service.
Probably should acknowledge that I understand why you wouldn't want to include system modules like Active Directory or IIS management for the obvious issue that could lead to but I'm only trying to include custom functions in a single disputable non editable way.
I have used PowerGUI in the past but can't find any valid exe's for that since DELL have removed it and from memory, I don't think I've ever used it with a module.
I've tried PS2EXE-GUI and PS2EXE. Both of these make the exe and everything works fine while the modules exist. However, as soon as I put the exe on a server that hasn't got the Modules deployed to it, it fails to run. I thought the compile followed all the dependencies and included them as part of the build into the single exe? That appears to not be the case.
I've also tried the PowerShell Studio 2018 by Sapien, but based on their forums you can't include modules into the complied exe. Which again feels wrong if they are actually just custom functions, but it's the way they've written it.
I see https://poshtools.com/docs/posh-pro-tools/merge-script/ would possibly do what I need but that's chargeable and it looks like it actually merges all the content back into a single file. Given the time pressure I'm starting to think I'll have to pay if there are really no other better options. I just don't have time to join everything together manually and I can't help thinking there is a better way I'm missing!
Can anybody please suggest other options?
Could I also get clarification around my original mantra (functions go in modules...)?
"No, never!" or "Yes, always!" or "It's just wrong in this scenario."

Changing Code At Runtime While Debugging

I am using Eclipse Kepler Service Release 2 , EPIC 0.5.46 and Strawberry Perl 5 version 18 for perl programming. For debugging I am using Eclipse debugger and PadWalker .
I have an interactive perl program that writes to files based on answers provided by the users to multiple prompts. While debugging , every time i change a single line of code I have to rerun the whole program again and provide inputs to every prompt , which is really time consuming.
Is there a way to make changes to the code in a sub routine , in the middle of debugging session such that the instruction pointer resets itself to the first line of that sub routine. This way i do not have to restart the session to recompile the new code.
Appreciate your inputs and suggestions. Thank You!!!
What you want to do can be done, and I've done it many times in Perl myself. For example, see this.
However although what you describe may work (and is a bit dangerous), the way it is generally done a bit different and safer.
First one has to assume a regular kind of command structure like a command processor, or say a web server.
In a command processor or web server, you read a command (or get a web request), perform an action, then read another command, perform another action and so on. From your description, it sounds like you have such a structure.
In my case, I have each debugger command stored as in Perl file. This is helpful not only for facilitating this task, but also for understanding, testing and changing the code.
Given this kind of program structure, instead of trying to change the program counter, you complete the command and at the level where you are about to read a new command, you make the change and then reload the file which changes the code.
The specific Perl construct to do this is called do. Don't use require or use which will load in a Perl file only if that file or module hasn't been previously loaded. In your situation, you want to reload even if it has been loaded before.
So now how do you get to be able to issue a do command? As you suggest, you could do it through a debugger. Assuming you have this overall program stucture as described above, you put the breakpoint somewhere a common point in the caller which loops over things to process, rather than try to change things in indvidual commands.
And you don't even need a debugger to do this! Many web frameworks like Ruby on Rails, have a "development" mode where they save timestamps on files that implement functionality. If the file has changed they issue the "do" command before running the request.

Integrating external highlighter tool in Eclipse editor

Okay, this is probably easy, but I don't know proper words to describe it, and hence, google it...
I have an external script which takes a file name and outputs this:
/path/to/file.py:683:80: E501 line too long (85 characters)
/path/to/file.py:690:21: other error message
..etc..
Now, I know this output format is widely accepted by other, much simple IDEs, e.g. EditPlus. I don't know how to integrate it with Eclipse though.
I want this script integrated with my editor windows. I want Eclipse to run it in the background, every time I save the file, and then parse the results and mark all the lines which occured in the script's output. It should look something like this:
How can I do that?
Note (for those who know why I need this): I know PyDev has a pep8.py checker integrated, but it's not enough.
Ok, so I implemented that plugin myself. I does exactly what I asked for, I guess. I made it configurable with some rude regular expressions.
I posted the code and installation instructions here (GitHub).
Your own plug-in that runs the script and examines its output can create Markers from that output. See http://www.eclipse.org/articles/Article-Mark%20My%20Words/mark-my-words.html .

Making and Interfacing with Custom Services

I've been searching for this for awhile now, and I am not sure if I am just not using the correct search terms or if the answer is really that hard to find.
What I am trying to do is to create a new Windows service for a game server from a batch file, and then have a task run another batch file every 30 minutes or more that would run two commands on the game server's command line and do some file work.
Specifically, I am running a Minecraft server using Bukkit for a gaming community I help run, and I want to make sure that the thing is always up unless I specifically tell it to stop (like a service). Bukkit is run directly from a batch file and has it's own command line thing running on it.
I am told that you CAN run this type of thing as a service, but the command line will be hidden from view and/or interaction. This is the second part of my query. I have a handy little backup.bat file that copies all the world files and userdata files into a backup directory, 7zips it, and deletes the directory. The only thing is, is that Minecraft likes to always have the worlds' region files open and writing at all times, meaning that it could cause map corruption if I just run it straight off. To compensate, I need to run the command "save-off" on the server to disable the file hooks temporarily, run the backup, and as soon as it finishes, run "save-on" so that the game can continue without lost data.
What I would like to know about this second one is, is it possible to interface with the game service through a batch file, or do I need to create an application to do that? If the latter, how exactly does one go about doing that? I have moderate C++ knowledge (up through my second OO-C++ course in college), and can possibly learn another language if absolutely necessary.
So, in short, two questions:
1. Is it possible to, and how to run a BAT file as a Windows Service?
2. How to interface with said service via BAT files, and if not possible, what kind of application do I need to write (redirection to or writing a tutorial works for me).
Thank you in advance for any and all help!
Old question, user account doesn't seem active on SO anymore, but hey, if you stumble upon this because you have a similar problem:
Since we are speaking about a Bukkit Minecraft server, turn to the "Essentials" plugin for Bukkit.
It now includes a Backup function that does exactly what the OP asks for, namely stop the save so the files can be manipulated without corruption, launch a script, then starts again.
The script can be a backup one (examples provided in the linked page) but can be used to run any operation on the world's files.