Dynamic User in .bat file - ms-access

This is my first time trying to use .bat files. I am trying to make one that keeps my front end of my Access database on the most current version for users (only ~7).
I am using:
md C:\Users\tmyers\Desktop
del C:\Users\tmyers\Desktop\Quotations.accdr
copy "\Users\counter1152\desktop\PM DESKTOP FILES\Lighting Project Management Application\Quotations.accdr" C:\Users\tmyers\Desktop
C:\Users\tmyers\Desktop\Quotations.accdr
Part of the copy string I removed due to being the path to our server (just in case). I need the user to somehow be dynamic based on the person executing the file. I could make a special .bat file for each person since I dont have many users, but that seems sloppy.
As a secondary question, how can I get the cmd prompt window to not show when this is executed? That would just be a personal preference of mine. I did find https://superuser.com/questions/140047/how-to-run-a-batch-file-without-launching-a-command-window for reference but am not 100% sure how to do wscript.

try with :
md "%userprofile%\Desktop"
del "%userprofile%\Desktop\Quotations.accdr"
copy "\Users\counter1152\desktop\PM DESKTOP FILES\Lighting Project Management Application\Quotations.accdr" "%userprofile%\Desktop"
"%userprofile%\Desktop\Quotations.accdr"
To auto-hide the cmd.exe window you can use windowmode.bat and getCMDPid.bat:
call getcmdbit.bat
call windowmode.bat -pid %errorlevel% -mode hidden

Related

Keyboard short for uploading two files in PhpStorm

The problem
In PhpStorm I have a style.css- and a app.js-file that I have to upload to a server over and over again. I'm trying to automate it.
They're compiled by Webpack, so they are generated/compiled. Which means that I can't simply use the 'Tools' >> 'Deployment' >> 'Upload to...' (since that file isn't and won't every be open).
What I currently do
At the moment, every time I want to see the changed I've done, then I do this (for each file):
Navigate to the files in the file-tree (using the mouse)
Select it
The I've set up a shortcut for Main menu >> Tools >> Deployment >> Upload to..., where-after I select the server I want to upload to.
I do this approximately 100+ times per day.
The ideal solution
The ideal solution would be, that if I pressed a shortcut like CMD + Option + Shift + G
That it then uploaded a selection of files (a scope?) to a predefined remote server.
Solution attempts
Open and upload.
Changing to those files (using CMD + p) and then uploading them (once they're open). But the files are generated, which means that it takes PhpStorm a couple of seconds to render the content (which is necessary before I can do anything with the file) - so that's not faster.
Macro.
Recording a macro, uploading the two files, looking like this:
If I go to the menu and trigger the Macro, then it works. So far so good.
But if I assign a shortcut key and trigger that shortcut while in a file, then it shows me this:
And if I press '1' (for it to upload to number 1 on the list), then it uploads the file that I'm currently in(!?), and not the two files from my macro.
I've tried several different shortcuts (to rule out some kind of keyboard-shortcut-clash):
CMD + Option + CTRL + 0
CMD + Shift 0
CMD + ;
... Same result.
And the PhpStorm Macro's doesn't seem to give me that many options anyways.
Keyboard Maestro.
I've tried doing it using Keyboard Maestro.
But I can't get it setup right. Because if it can't find the folders (if they're off-screen or if I'm in a different project and forgot to adjust they shortcuts), then it blasts through the rest of the recorded actions, resulting in chaos. Ideally it should stop, if it can't find the file on the screen.
Update1 - External program
Even if it's not possible to do in PhpStorm, - are there then another program that I could achieve this with?
Update2 - Automatic Deployment in PhpStorm
I've previously used this, - but I've had happen a few times that I started sync'ing waaaay to many files, overwriting critical core files. It seems smart, but can possibly tear down walls if I've forgotten to define an ignore properly.
I wish there was an 'Automatic Deployment for theses files'-function.
Update3 - File Watchers
I looked into file-watchers ( recommendation from #LazyOne ). Based on this forum thread, then file watchers cannot be used to upload files.
It is possible to accomplish it using external program scp (Secure Copy Protocol):
Steps:
1. Create a Scope (for compiled files app.js and style.css)
2. Create a Custom File Watcher with scp over that Scope
Start with Scope:
Create a Local Scope with name scp files for your compiled files directory (I will assume that your webpack compiles into dist directory):
Then, to add dist directory into Scope, select that folder and click on Include Recursively. Apply and Move to File Watchers
Create a custom template for File Watcher:
Choose a Name
Choose File type as Any
Choose Scope as scp files(created earlier)
Choose Program as scp
Choose Arguments as $FileName$ REMOTE_USER#REMOTE_HOST:/REMOTE_DIR_PATH/$FileName$
Choose Working directory as $FileDir$
That's it, basically what we have done is every time when a file in that scope changes, that file is copied with scp to the remote server to the corresponding path.
Voila. Apply Everything and recompile your project and you will see that everything is uploaded to the server.
(I assumed that you have already set up your ssh client; Generated public/private keys; Added a public key in your remote server; And, know ssh credentials to connect to your remote server)
I figured this out myself. I posted the answer here.
The two questions are kind of similar but not identical.
This way I found is also not the best, since it stores the server password in clean text. So I'll leave the question open, in case someone can come up with a better way to achieve this.

Create a standalone form shortcut in Microsoft Access 2013

I currently have a functioning form that searches through my database by calling a query. What I'm trying to do is turn this into a standalone application where I can simply open a file and only the form opens, running the database on the back-end. I have tried running a macro that opens the form, and I have tried creating a shortcut to my desktop, but nothing has worked.
Does anyone have any suggestions? Anything that will only show the form and the search results would be good (desktop shortcut, HTML file, etc.).
Thanks!
You will need to split your database so that the tables are located in a separate back-end file (which can be kept on a server). These instructions apply to Access 2007 and 2010 but the process is very similar for 2013.
Once this is done, your tables will become linked tables (stored in a separate file) and your front-end .addcb file will only contain queries, forms and reports.
You can control which form opens when the application loads through File -> Options -> Current Database. There are also several other useful controls here for limiting what the user can do; ie.
Hiding the list of database
Hiding the tabs (you will therefore need to create buttons to move between forms)
Hiding the Ribbon and/or status bar
Disabling Layout View
It's safest to change these settings on a copy, so you don't inadvertently lock yourself out; however, by holding down shift when opening the file from within Access, most of these options will be bypassed and you will be able to edit the database / revert these settings should you need to.
In terms of making it a "stand-alone application", it is possible to create a copy that will open without requiring the full version of MS Access on the user's PC (instead using Access Runtime).
I always distribute my front-ends as .accde format (File -> Export ACCDE). The benefits are as follows:
Smaller file size
Optimise memory usage / improves performance
VBA code runs but cannot be viewed or edited
I think what you're looking for is here:
http://office.microsoft.com/en-us/access-help/command-line-switches-for-access-HA010166605.aspx
and
http://office.microsoft.com/en-us/access-help/command-function-HA001228801.aspx
Basic idea, create a macro called AutoExec that checks for a command line argument when opening the database. Setup a shortcut with a command line argument (whatever you decide to name it, I'll use 'lookuponly' as the example.) like this:
"C:\Users\%Username%\Desktop\MyDatabase.mdb" /cmd "lookuponly"
when you double click the shortcut it should auto-run the macro and open your lookup form. Of course under newer versions of access you'll have to set the location of the database as a trusted location or access will attempt to block the database.
http://office.microsoft.com/en-us/access-help/decide-whether-to-trust-a-database-HA010256412.aspx

Opening an Access Form from a hyperlink

We currently have an ASP/SQl Server system, which has an option to send an e-mail to a user. This e-mail contains a hyperlink to another ASP page, which shows a specific database record.
I'm currently working on a resilience version of the system, which is MS Access based. The user's would like to keep the same functionality, and have an e-mail which contains a hyperlink back to the database, opening a specific form and filtering it to a record.
I believe the solution lies somewhere in using Command() to get the parameters from the command line, however I am actually having difficulty currently opening the database itself. The code i'm currently using is:
<a href="C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.exe
H:\Access DB\11th March\Link to DB\Dealer
Startup Admin EU v10.mdb" >
TEST
</a>
I think this should open the Dealer Startup database, however it is failing stating the file cannot be found. If I remove the second step i.e. H:\Access DB etc. the link opens Access, so I am wondering if i'm doing something syntactically incorrect? The file path definitely seems right.
Also would someone be able to give some advice on the use of /c in a hyperlink? The small amount of information I have found seems to suggest it doesn't work but if someone could clarify or give me an example of how to do it I would appreciate it
Thanks,
Chris
I managed to create a solution to this problem. I could not find a direct way to open the Access DB from a hyperlink, however you can hyperlink to a shortcut. The workaround I therefore used was to create a shortcut to the database using the following syntax:
"file path to ms access" "file path to database" /cmd Args
so for example:
"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.exe" "C:\Documents and Settings\Database.mdb" /cmd Args
Creating a shortcut to this file path opens the database. I then created an autoexec macro which opened a specified form if the Command() function returned Args. This meant that when opening the database normally you would be taken to the usual form, but when opening from the shortcut you will be taken to a different form.
I then created the e-mail hyperlink to the shortcut.
I have created a batch file to delete browser history for MSIE and kept it on the server-side. When the user clicks on 'delete browser history' hyperlink, I just make him download this file, and the user runs it manually.
You can also do something similar.

TCL/TK - Get Desktop path

My TCL/TK application prompts the user to choose a location where to save a file.
What should the value of the -initialdir option be so that the Desktop is the default location?
I tried %userprofile%\desktop, but it's not working.
set dir [tk_chooseDirectory -title "Where do you want to save the config file?" -initialdir %userprofile%\desktop]
Thanks
The safest way is to use twapi's get_shell_folder command with the argument "csidl_common_desktopdirectory" to get the path to the "all users" desktop directory, or "csidl_desktopdirectory" to get the current user's desktop.
If you don't want to depend on twapi, the paths can be found in the registry, but I don't know how reliable it is. For example:
package require registry
puts [registry get "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" "Desktop"]
This returns "%USERPROFILE%\Skrivbord" on my system. You still have to expand the USERPROFILE variable (and any other variables). That's best done with twapi::expand_environment_strings, but since you're not using twapi, try regsub:ing %USERPROFILE% with $env(HOME) instead.
Or if you don't care about people with non-english Windows, just use "~/Desktop".

Post build event command whose directory is not C:\

I want to run a command in the post build event of a project, if i do C:\temp\Client.exe it works fine but If my project is in the thumb drive and change the command to G:\temp\Client.exe it looks like it doesnt like the path and exit with code 9009. what command do i need if the exe is in different path than C drive. Thankx
From the question and subsequent comment it looks that drive letter keeps changing. It is possible in post-build section check if the file exist before call it.
For debugging you can use something like
f:
Dir
And view output window after the build.