Question

Change default batch script .bat to open with cmd a non extencion file

Asked by: compuiter

I need a batch script or registry file that adds for a non extencion file to open just like a batch script .bat file when you double click it

And the batch script or registry file that reverts this, that takes it back the way it was just before.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-10-18 at 09:36:55ID24821789
Topic

Windows Batch Scripting

Participating Experts
2
Points
500
Comments
32

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. running bat
    how do i, in windows 2000 server, run a .bat when the computer starts. i want this to run before people log in, so putting it in the startup folder or login script is not good
  2. bat file self delete
    I have a little problem. I have a file that runs and updates sertain registry settings. it is just a little .bat file that runs and then calls the .reg file which gets added into the users registrty. The bat file is only suppose to run once. I want the .bat file to delete...
  3. .bat file
    I try the example #1) at http://www.geekpedia.com/tutorial17_How-to-bat-and-jar.html but when i run double click the incon, it is tell me: Exception in Thread "main" java.lang.NoClassDefFoundError: HelloWorld1 Any idea why this?
  4. registry entry will open photoshop but not a .bat file
    ok I have a registry entry called myprog under it I have shell/open/command and in that command I have the default string point to the photoshop exe So now I can go to the run box and type myprog: and photoshop opens right up so I then go to that string thats pointing t...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: dragon-itPosted on 2009-10-18 at 09:47:33ID: 25600450

Have you looked at assoc.exe?

Not sure if it would work for extensionless and can't try at the mo.

If it does I guess it would be:

assoc .=txtfile
and then
assoc .=

to remove it

Steve

 

by: dragon-itPosted on 2009-10-18 at 09:55:12ID: 25600481

Actually just booted up a machine to look, assoc is built in command but principal is the same... what I have put above should work OK to launch notepad and the like but if you want it to run as a batch file use either
batfile or cmdfile instead of txtfile... except on mine I then get "xxx.a is not a valid Win32 application" and "access is denied".

So not sure

Steve

 

by: compuiterPosted on 2009-10-18 at 12:17:17ID: 25600975

It didnt work either with my tests, i get is not a valid Win32 too..

I tryed using the batch script:

assoc .=batfile


When i run that script it associates the icon for a batch script, so i need to solve this two things:

First i need to the batch script with non extension work and not getting is not a valid Win32.

Then i need to make the new batch scripts with no extensions to have the default non associated files icon.

 

by: dragon-itPosted on 2009-10-18 at 16:10:36ID: 25601819

OK.... how about

assoc .=mycmdfile
ftype mycmdfile=cmd /c "copy %1 x.cmd & call x.cmd"
set pathext=.;%pathext%

to remove
assoc .=
ftype mycmdfile=
set pathext=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH

Steve

 

by: dragon-itPosted on 2009-10-18 at 16:16:10ID: 25601834

Odd. Had that working once then it didn't.... FAR too late now will think again tomorrow if t0t0 hasn't been along and nicke thepoints :-)

 

by: compuiterPosted on 2009-10-21 at 00:00:41ID: 25621282

Hello dragon-it could you find out how this could be done?

 

by: compuiterPosted on 2009-10-25 at 16:40:01ID: 25659026

Help!! Anyone?

 

by: compuiterPosted on 2009-11-01 at 13:22:04ID: 25715549

Hello, is the question or what i need to do clear enough? or should i change it for something easyer to understand?

 

by: dragon-itPosted on 2009-11-01 at 14:29:12ID: 25715906

Sorry, I don't know whether that is possible or not off hand and haven't got time for EE questions right now due to a new baby.  Please click on the "request attention" link and it will trigger alerts to other experts.

Steve

 

by: compuiterPosted on 2009-11-01 at 22:20:20ID: 25717378

I have done that a couple of times but i didnt get a respond, thanks!, and congratulations for your new baby.

 

by: dragon-itPosted on 2009-11-01 at 23:26:58ID: 25717541

ok, and thanks.  I'll ask a few of the other experts here see if they know any more.... what I did above seemed to work when it was an '.XXX' file or whatever but for a non extension it doesn't.   Will experiment when I have time and see if I can rouse some more help.

 

by: Netman66Posted on 2009-11-02 at 04:59:10ID: 25718903

Not possible.

You can tell by the GUI when you right click a file with no extension and select Open - the option to Always use the selected program is unavailable to select.

Is there any reason why you can't simply add a file extension to your file?

 

by: dragon-itPosted on 2009-11-02 at 06:58:46ID: 25719916

Thats what I thought originally ... though adding it to the pathext variable seems to make it open into IE as a text file for me oddly.

and doing

assoc .x=mycmdfile
ftype mycmdfile=cmd /c "copy %1 x.cmd & call x.cmd"

works for other extensions such as .x above but for . doesn't..

Steve

 

by: compuiterPosted on 2009-11-08 at 16:50:53ID: 25772792

Netman66 i need to hide as much as possible the source code for some scripts.


dragon-it

The .x scripts open has a cmd window but they dont work, if this cant be donde without  file extencions setting one is better than nothing.. So we can try with .xxx extencions.

If someone knows how to do it without one ill try again.


assoc .x=mycmdfile

ftype mycmdfile=cmd /c "copy %1 x.cmd & call x.cmd"

 

by: dragon-itPosted on 2009-11-08 at 22:46:32ID: 25773791

you need the pathext variable set too I think to say this is an executable - can you explain how you want this to work again, I.e. are we talking that you want a .xxx extension on someones desktop to click say...

How will that stop them looking/knowing it is a script if you expect them to run it?

You could always have a script that copies a script from a network location that is 'hidden', runs it and deletes or similar etc. though if the user has the rights to run/copy it then they can read it too.

Maybe you need to write this in VB or C and compile into an exe, or I think there are some batch compilers too?

Steve

 

by: compuiterPosted on 2009-11-08 at 23:41:16ID: 25773994

Yes i have batch compilers but it can be easyly get the source scripts, i need to go as further that i can, i have a couple ideas i worked on, this scripts with no extencions are really for the temp folder maybe they wont notice it is a batch script and will not run on other computers if they are extracted and i am making them to work automaticly they wont be for the user to open them, i hope you get the idea. I cannot use VB or C because i dont know the language.

If you can do the batch script with real code at least for .xxx i can understand it and edit it to what ever i want i hope you can help with it.

 

by: Netman66Posted on 2009-11-09 at 15:56:07ID: 25781314

 

by: dragon-itPosted on 2009-11-09 at 22:57:42ID: 25782971

Ill try it again myself later from a clean machine but the code I posted before should work from the cmd.exe window you are in.  Otherwise the pathext variable may need changing globally from control panel, user environment in system.

Anyone savvy enough to look in the temp folder would probably be capable of spotting an odd file like this but I imagine in terms of usefulness:

1. Mark the file hidden and/or system - explorer will hide these unless someone has unhidden such files in the options (i.e. a techie).

If they are temporary batch files could they not be deleted at the end of the script with a DEL command?

How are they created, and what sort of things are they doing I.e. does another script run them or the user from an icon (in which case they could right click and open with notepad anyway).

If they are running from another script then hide the files with attrib command, rename .cmd to .tmp or something and when your other script comes to run it rename .tmp to .cmd etc..

Sorry for all the 'it depends'!

 

by: compuiterPosted on 2009-11-15 at 18:41:36ID: 25827537

Netman66 is there  way to run the encoded file without deconding it? as a batch script, a b64, exe or any other file? or can it be converted it to exe, batch, vbs when encoded and run it like that?.


dragon-it can i add the path ext globally variable from a batch script or reg file?

The temporary batch files can be deleted but while installing they can be extracted, some program take too long with the script open because they take a long time to install.

There is a compiled main script that extracts the temp batch script and that script calls other scripts and programs, but the rest of the scripts are batch scripts.

I already use the renaming but there is a time window when the script is exposed and i need to do this the safest way i can. The base64 its a good idea if it could be run encripted or encoded.


The non extension / or other extension runing as a batch script its a great idea because they  extract the file they wont work on other computers, so if that could be done its a little better than what i have right now. Anyone knows how what can be made?

 

by: Netman66Posted on 2009-11-15 at 19:46:14ID: 25827695

An encoded file runs as it normally would.

 

by: compuiterPosted on 2009-11-16 at 04:41:33ID: 25829623

But i have to convert it back decoding it to a batch script? or it runs just like a batch script?, because i cant open it when its encoded.

Or how can i do to run it encoded, just if like it where a batch script?

 

by: Netman66Posted on 2009-11-16 at 06:35:43ID: 25830506

What happens if you leave the extension as a .CMD or .BAT?

VBScript can be encoded and saved as a .VBE using SRCENC then run normally.

http://www.microsoft.com/downloads/details.aspx?FamilyId=E7877F67-C447-4873-B1B0-21F0626A6329&displaylang=en

 

by: compuiterPosted on 2009-11-16 at 09:47:48ID: 25832164

I need to have the source code encripted, that cannot be taken or viewed but still have to run the scripts.

This SRCENC converts only  vbs scipts to vbe? i really dont understand vbs.

Could this work on batch script files?, i understand them much better, i took a look on SRCENC but didnt understand what kind of files or how to manage them.

The base64 scripts are great only if i could run them encoded, and if they would work just like a batch script.

Any other ideas on how i can do this, if they get the files but they cant run them on other computers without the programs or asosiating a non extension file, lets say its a batch script with .tmp extension, if they get that file they wont be able to run on other computers.

Does exist a visual studio, c#, delphi or other small compiler that i can convert the .bat scripts to .exe but that dont leave .bat files hidden on temp folder with the source code?.

 

by: Netman66Posted on 2009-11-16 at 10:22:31ID: 25832488

I would imagine you could create an EXE if you know how to right in a language in Visual Studio that can be compiled.

SRENC converts VBS to VBE (or encoded so you cannot read it) but still runs as a VBS would.

A tool called BAT_TO_EXE_CONVERTOR should work:

http://www.computerhope.com/dutil.htm

 

by: dragon-itPosted on 2009-11-17 at 01:26:52ID: 25838073

Well it seems for any extension you can do this without the pathext bit:

assoc .y=mycmdfile
ftype mycmdfile=cmd /c "copy /Y %1 "%temp%\x.cmd" & call "%temp%\x.cmd""

and then it will load from explorer double click or from a batch file / run box etc. by typing

mybatchfile.y

or call mybatchfile.y from a another batch etc.

You can remove afterwards with

assoc .y=
ftype mycmdfile=

Steve

 

by: compuiterPosted on 2009-11-17 at 07:39:30ID: 25840709

Im getting a error message the system cant find the specified file when running newbatch.y

I think its x.cmd that is causing the error on temp folder.


When its running fine how would i change de extension? only the .y to new extension .new?

assoc .y=mycmdfile to assoc .new=mycmdfile


Does x.cmd carries the original batch script code?


 

by: dragon-itPosted on 2009-11-17 at 08:10:27ID: 25841064

Correct.  Yes it still has to rename it to .cmd to run it... (which I know defeats the object a bit!)
Steve

 

by: compuiterPosted on 2009-11-18 at 06:52:00ID: 25850288

Hey dragon-it did the last script worked well for you?

Maybe can this be done programed on other any language to make it and undo, and then i can call them when the script starts and when the script ends.

Anyone can do it?

 

by: Netman66Posted on 2009-11-18 at 06:55:03ID: 25850317

Did you try the BAT-to-EXE convertor above?

 

by: compuiterPosted on 2009-11-18 at 06:59:59ID: 25850388

Yes, i have tryed most of those programs, it looks like thisone its working the online compiler didnt work i didnt know if it was the program or the online one that left the source on temp folder, im just making my tests but im also trying to make what i originally want to do.

 

by: dragon-itPosted on 2009-11-18 at 07:05:18ID: 25850436

Yes the assoc and ftype worked for me (just typing those at .cmd prompt then you can do start | run something.x or type something.x from cmd.exe prompt BUT it does leave the script in tmp as a .cmd....

 

by: compuiterPosted on 2009-11-22 at 04:13:24ID: 31642646

Thanks guys for the effort if you find a way that runs directly with other extension file and not converting it to cmd or bat please let me know, i thought this was a little easyer.

Regards

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...