0

I have seen mentions in other places to a -regserver argument to cscript or wscript - but can't find any info that precisely defines what this option does or really clarifies when you'd want/need to use it.

Even the built-in help does not mention it:

λ cscript /?
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

Usage: CScript scriptname.extension [option...] [arguments...]

Options:
 //B         Batch mode: Suppresses script errors and prompts from displaying
 //D         Enable Active Debugging
 //E:engine  Use engine for executing script
 //H:CScript Changes the default script host to CScript.exe
 //H:WScript Changes the default script host to WScript.exe (default)
 //I         Interactive mode (default, opposite of //B)
 //Job:xxxx  Execute a WSF job
 //Logo      Display logo (default)
 //Nologo    Prevent logo display: No banner will be shown at execution time
 //S         Save current command line options for this user
 //T:nn      Time out in seconds:  Maximum time a script is permitted to run
 //X         Execute script in debugger
 //U         Use Unicode for redirected I/O from the console

and nor does Microsoft's documentation.


Note - I gather from some of the external articles I linked to that this option can be used to recover from some bugs in Windows XP and maybe also Vista. But that doesn't actually explain what this option DOES or why it exists. I don't think Microsoft added it after the fact as a FIX, but rather people could take advantage of it to address whatever those problems were in XP/Vista.


EDIT: Just because two questions have same/similar answers does not make them duplicates. The same information can answer multiple different questions. The question referred to as a potential duplicate doesn't have anything to do with the scripting executables. The value of THIS question is that someone using those tools can actually search and find an answer. They will not readily find the other one (as I did not when extensively searching/Googling before I posted this).

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
  • 3
    Possible duplicate of [What is difference between RegSvr and RegServer?](https://stackoverflow.com/questions/3051823/what-is-difference-between-regsvr-and-regserver) – user692942 Apr 19 '18 at 12:51
  • @Lankymart I'm not asking about RegSvr32 at all. I'm asking about an argument to wscript which happens to have a similar name. – StayOnTarget Apr 19 '18 at 17:52
  • Read the article. It’s talking about the `-regserver` / `/regserver` switch, it’s in relation to registering COM executables. It is not a switch specific to `wscript.exe` which is why you can’t find it in the documentation/ help. Just read the upvoted answer - *”EXE COM servers can be run directly, so this is what you do passing them `/regserver` or `/unregserver` parameters.”* It’s not different it’s the same thing, which you would realise if you read the answer, hence the dup flag. – user692942 Apr 19 '18 at 17:55
  • @Lankymart thank you I see what you mean now. That other question could be improved itself to make that more clear. – StayOnTarget Apr 19 '18 at 17:59

1 Answers1

1

These are not actually unique arguments to cscript or wscript; rather they are standard arguments in Windows to any EXE which can act as a COM server.

See this related question for more details of how they operate: https://superuser.com/questions/1164298/what-actually-happens-during-regserver-unregserver

This is at least partly documented here:

If the server is packaged in an EXE module, the application wishing to register the server launches the EXE server with the command-line argument /RegServer or -RegServer (case-insensitive). If the application wishes to unregister the server, it launches the EXE with the command-line argument /UnregServer or -UnregServer.

The self-registering EXE detects these command-line arguments and invokes the same operations as a DLL would within DllRegisterServer and DllUnregisterServer, respectively, registering its module path under LocalServer32 instead of InprocServer32 or InprocHandler32.

Community
  • 1
  • 1
StayOnTarget
  • 11,743
  • 10
  • 52
  • 81